in reply to Sockets: TMTOWTDI (BWWIB)?

First, I'd recommend a good TCP/IP book. I learned from the Comer/Stevens series. I would recommend you pick up one of the following: Internetworking with TCP/IP, Volume III, BSD version, Windows version, linux/POSIX version. http://www.bookpool.com is a good place to get technical books at a discount. Somebody else here might have some other book recommendations but I've always heard good reviews about this series.

As far as handling connections goes, you have the following choice:

Which way is best is for you to decide. What works best on one platform may not work well at all on another. Try to separate your network interface from the rest of your code so that you can try implementing it in different ways.

As a disclaimer, I've written many network servers but usually in C/C++. I've never tried to do one in perl.

--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Replies are listed 'Best First'.
Re^2: Sockets: TMTOWTDI (BWWIB)?
by Ionizor (Pilgrim) on Dec 17, 2002 at 05:15 UTC

    Thank you. I found this thread very helpful and informative. Unfortunately the book you've noted is a bit out of my price range and my Christmas gifts have already been bought.

    I've eliminated the "open, read, write, close" model because the overhead is too high. I want the server to be able to handle a load of a few hundred concurrent users, even if it doesn't ever scale that high in actuality.

    Given the problems with fork() in Windows I've eliminated it as well as I don't currently have a Unix machine to test on. This may change in future.

    This leaves me with threads and select(). I am still weighing the benefits and drawbacks but I'm leaning towards select() switching. I've taken your advice and the model I've drawn up for the server has the networking core abstracted with an API so I can switch the underlying implementation as it becomes prudent to do so.

    Is there a specific reason you've never written network servers in Perl? (i.e. am I missing something important?)

    Thank you once again for sharing your perspective.

      Is there a specific reason you've never written network servers in Perl? (i.e. am I missing something important?)

      You're not missing anything. Most of the network servers I've written have been done as part of my job. The situations called for coding in C/C++. Most of my personal stuff has been written to run as web-based applications and are written in perl.

      --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';