Guest User

Untitled

a guest
May 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/socket.h>
  3. #include <netinet/in.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <arpa/inet.h>
  8. char message[] = "WTFffffffff";
  9. char buf[sizeof(message)];
  10.  
  11. int main()
  12. {
  13.     int sock;
  14.     struct sockaddr_in addr;
  15.  
  16.     sock = socket(AF_INET, SOCK_STREAM, 0);
  17.     if(sock < 0)
  18.     {
  19.         perror("socket");
  20.         exit(1);
  21.     }
  22.  
  23.     addr.sin_family = AF_INET;
  24.     addr.sin_port = htons(666);
  25.     addr.sin_addr.s_addr = inet_addr("10.62.100.37");
  26.     if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
  27.     {
  28.         perror("connect");
  29.         exit(2);
  30.     }
  31.  
  32.     send(sock, message, sizeof(message), 0);
  33.     recv(sock, buf, sizeof(message), 0);
  34.    
  35.     close(sock);
  36.  
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment