a quick tangential question about sockets in perl ..

JP May (jpm@rootworks.com)
Thu, 23 Apr 1998 13:35:25 -0600


Say you write a small server that sits there and spits out, maybe the time or just a random sentence, let's say.  (No input, it just spits something out.)  Say you run it on port 2001 of your unix server to make it concrete.

I have discovered the following:

Say you then write a tiny client, in perl, which simply accesses that server, gets the output (the time or whatever) and prints it out.

Of course, you could also just use telnet localhost 2001 to achieve the identical thing.

Here is the question:

no matter WHAT I try, I cannot write a Perl client that does this, as **FAST**, as "telnet localhost 2001' does it.

At first I thought it was due to going 'via the internet', but I have tried writing the client totally internally to the box, ie only using PF_UNIX only not PF_INET protocol, as a socket, and it's the SAME delay.

The delay (maybe half a second? .. compared to instantaneous with telnet) is not related to perl overhead or what have you, there is definitely some sort of slow down in there.

It is MYSTERIOUS.

I MUST be doing something wrong, somewhere with a socket, or there must be a better way.

Anyone know about this particular mystery??  Thanks!

-JPM