Written 1999-07-12
This program:
char a[99]=" KJ";main(int c,char**v){int s=socket(2,1,0);char*p,*t=strchr(*++v ,'@'),*o=a+4;*(short*)a=2;p=t;while(*p)(*p++&48)-48?*o++=atoi(p):0;connect(s,a, 16);strncpy(a,v[1],7);a[7]=':';a[8]=32;if(fork())while((c=read(0,a+9,90))>0)( write(s,a,c+9)>0)||exit(0);else while((c=read(s,a,99))>0)write(1,a,c);}
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 @1.2.3.4 Robert
. . . where 1.2.3.4 is the IP address of the machine where you are running the server, and Robert is your name. You can read a line-by-line explanation of what this client 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.