#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int
main()
{
	struct sockaddr_in sin;
	int fd, r;

	fd = socket (PF_INET, SOCK_DGRAM, 0);
	if (fd < 0) {
		perror ("socket");
		return 0;
	}
	sin.sin_family = AF_INET;
	sin.sin_addr.s_addr = htonl (INADDR_ANY);
	sin.sin_port = htons (5555);

	r = bind (fd, (struct sockaddr *)&sin, sizeof (sin));
	if (r < 0) {
		perror ("bind");
		return 0;
	}
	while (1) {
		size_t len = sizeof (sin);
		static char buf[10000];

		r = recvfrom (fd, buf, sizeof (buf), 0,
			(struct sockaddr *)&sin, &len);
		if (r < 0) continue;
		r = sendto (fd, buf, r, 0, (struct sockaddr *)&sin,
			sizeof (sin));
	}
	return 0;
}
