Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #import "ViewController.h"
  2. #include <sys/types.h>
  3. #include <sys/socket.h>
  4. #include <arpa/inet.h>
  5.  
  6. @interface ViewController ()
  7.  
  8. @end
  9.  
  10. @implementation ViewController
  11.  
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. }
  15.  
  16. - (IBAction)clickedSendButton:(id)sender {
  17. int sock;
  18. struct sockaddr_in addr;
  19.  
  20. sock = socket(AF_INET, SOCK_DGRAM, 0);
  21.  
  22. addr.sin_family = AF_INET;
  23. addr.sin_port = htons(8888);
  24. addr.sin_addr.s_addr = inet_addr("192.168.100.101");
  25.  
  26. sendto(sock, "HELLO", 5, 0, (struct sockaddr *)&addr, sizeof(addr));
  27.  
  28. close(sock);
  29. }
  30. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement