Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement