+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#define PACKET_SIZE 1200
+
+
+int main(int argc, char **argv)
+{
+ int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ struct sockaddr_in addr;
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr(argv[1]);
+ addr.sin_port = htons(atoi(argv[2]));
+
+ bind(sock, (struct sockaddr *)&addr, sizeof(addr));
+ listen(sock, 255);
+
+ for ( ;; ) {
+ static char buf[PACKET_SIZE];
+ int seqno;
+ ssize_t len = recv(sock, buf, PACKET_SIZE, 0);
+ if (len == -1) {
+ perror("recv");
+ exit(1);
+ }
+ if (len < sizeof(int)) {
+ fprintf(stderr, "short packet\n");
+ continue;
+ }
+ memcpy(&seqno, buf, sizeof(int));
+ printf("%d\n", seqno);
+ }
+}