Advertisement
lutaco

Untitled

Jul 5th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/socket.h>
  3. #include <netinet/in.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. #define BUF_SIZE 64
  8. int main()
  9. {
  10. int sock;
  11. struct sockaddr_in addr;
  12. char buf;
  13. int bytes_read;
  14.  
  15. sock = socket(AF_INET, SOCK_DGRAM, 0);
  16.  
  17. addr.sin_family = AF_INET;
  18. addr.sin_port = htons(3495);
  19. addr.sin_addr.s_addr = htonl(INADDR_ANY);
  20. bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0;
  21. printf("%s\n", "la");
  22. while(1)
  23. {
  24. printf("%s\n", "la");
  25. bytes_read = recv(sock, &buf, 1, 0);
  26. printf("%s\n", "la");
  27. printf("%c", buf);
  28. printf("%s\n", "la");
  29. if (bytes_read<=0) break;
  30. }
  31. close(sock);
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement