How to run Kragen's second C .signature puzzle

Written 1999-07-12

This program:

char a[99]="  KJ",d[999][16];main(){int s=socket(2,1,0),n=0,z,l,i;*(short*)a=2;
if(!bind(s,a,16))for(;;){z=16;if((l=recvfrom(s,a,99,0,d[n],&z))>0){for(i=0;i<n;
i++){z=(memcmp(d[i],d[n],8))?z:0;while(sendto(s,a,l,0,d[i],16)<0);}z?n++:0;}}}

can be compiled on a Unix system with any C compiler, such as gcc, with a command-line like gcc -Wall junk.c. On some Unices, you might need to add some combination of -lsocket, -lxnet, and -lnsl to the end of the compile command line. Solaris needs either -lxnet or -lsocket.

This produces an executable called a.out. You can run it with a command line like this:

./a.out &

. . . and it will start running a network server. You can use this server by running the companion client. You can read a line-by-line explanation of what this server does if you like.

By the way, on a Linux system, you need to change socket(2,1,0) to something else -- I'm not yet sure what. The 1 is supposed to represent SOCK_DGRAM, but it's SOCK_STREAM on Linux.


Kragen's second C .signature puzzle | Kragen's home page