5 #include <sys/socket.h>
8 #include <netinet/in.h>
11 #define PACKET_SIZE 1200
14 int main(int argc, char **argv)
16 int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
17 struct sockaddr_in addr;
18 addr.sin_family = AF_INET;
19 addr.sin_addr.s_addr = inet_addr(argv[1]);
20 addr.sin_port = htons(atoi(argv[2]));
22 bind(sock, (struct sockaddr *)&addr, sizeof(addr));
26 static char buf[PACKET_SIZE];
28 ssize_t len = recv(sock, buf, PACKET_SIZE, 0);
33 if (len < sizeof(int)) {
34 fprintf(stderr, "short packet\n");
37 memcpy(&seqno, buf, sizeof(int));
38 printf("%d\n", seqno);