Or try it the UNIX-y way:
A Simple Socket Server Using 'inetd'. I found that to be a lot easier to work with. inetd spawns as many different copies on the same port as you need connections. That's why it's called the "super server". :) With inetd, everything from the specified port is sent to <STDIN> and everything from <STDOUT> is sent back. Remarkably powerful tool, makes socketing almost trivial! :D
Don Wilde
"There's more than one level to any answer."