Re: a quick tangential question about sockets in perl ..

Richard Nelson (richard.nelson@rhe.co.nz)
Sat, 25 Apr 1998 05:01:55 +1200


Greetings,

I have had similar experiences with writing mini-clients for accessing
sites over the internet in Perl using sockets. The response times have
in some cases been up to a minute longer compared with using a browser
or telnet. Much of the extra time seems to be consumed in the connect()
statement.

What is going on???

Regards,
Richard Nelson.
richard.nelson@rhe.co.nz

JP May wrote:
> 
> 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