It seems odd that you're apparently writing brand-new code in the year 2004, using
Socket like a Perl4 programmer being 10 years behind the times, instead of
IO::Socket, or even something that does most of what you're writing, like
Net::Server or
POE. Perhaps you should look around a bit more for better examples.