SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int socket_id = socket(AF_INET, SOCK_DGRAM, 0);
  2.     if (socket_id < 0) {
  3.         return 1;
  4.     }
  5.     struct sockaddr_in internetSocketAddress;
  6.     internetSocketAddress.sin_family = AF_INET;
  7.     internetSocketAddress.sin_port = htons(port);
  8.     internetSocketAddress.sin_addr.s_addr = inet_addr(ip);
  9.     unsigned int index = htonl(444440);
  10.     unsigned char buffer[11] = "444440\n";
  11.     memcpy(&buffer[7], (char*)&index, sizeof(index));
  12.     int bytesSent= sendto(socket_id, (const void*)&buffer, 11, 0, (struct sockaddr*)&internetSocketAddress, sizeof(internetSocketAddress));
  13.     printf("Content: %d;%X\n", index,index);
  14.     printf("buffer: %s", buffer);
  15.     printf("Bytes sent: %d", bytesSent);
  16.     close(socket_id);
  17.     return 0;
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
 
Top