SHARE
TWEET

Untitled

a guest Oct 10th, 2019 368 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/socket.h>
  4. #include <netinet/in.h>
  5.  
  6. int main(int argc, char** argv) {
  7.     int sockd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  8.  
  9.     struct sockaddr_in sockAddr;
  10.     sockAddr.sin_family = AF_INET;
  11.     sockAddr.sin_port = htons(8080);
  12.     sockAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  13.  
  14.     connect(sockd, (struct sockaddr*)(&sockAddr), sizeof(sockAddr));
  15.  
  16.     char buf[] = "set foo 0 0 6\r\nfooval\r\n";
  17.     send(sockd, buf, sizeof(buf), MSG_NOSIGNAL);
  18.     recv(sockd, buf, sizeof(buf), MSG_NOSIGNAL);
  19.  
  20.     shutdown(sockd, SHUT_RDWR);
  21.  
  22.     printf("%s\n", buf);
  23.     return 0;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top