[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

TCPSockets slooooooow

Christian Kaiser

1/11/2005 2:10:00 PM

Prereq:

- Ruby 1.8.1 on Windows

- Server and Client, communicating using TCPSockets, using a line-orientated
protocol like FTP

When the client connects from the same computer, everything is as fast as I
would expect it. When the client is on a different computer, it takes
minutes to complete even a few lines of protocol.

Does anybody have an idea how to change that behaviour? Can there be
something wrong?

If this is not enough info, please tell me what I should pass on.

Christian


-----
server.rb:

server = TCPServer.new($INTERFACE, $PORT)
while ($exitCode == 0 && session = server.accept)
...Thread.new(session) # whatever it does here for the protocol
(session.gets, session.puts, ...)
end # while

-----
client.rb:

session = TCPSocket.new(ARGV[0] ? ARGV[0] : 'localhost', ARGV[1] ?
ARGV[1].to_i : 64229)
puts session.gets
.... protocol using session.puts/session.gets



3 Answers

Dave Thomas

1/11/2005 2:22:00 PM

0


On Jan 11, 2005, at 8:11 AM, Christian Kaiser wrote:

> When the client connects from the same computer, everything is as fast
> as I
> would expect it. When the client is on a different computer, it takes
> minutes to complete even a few lines of protocol.
>

What happens if you call

BasicSocket.do_not_reverse_lookup = true

before the rest of your code?



Christian Kaiser

1/11/2005 2:46:00 PM

0

Dave,

unfortunately no change.

It's not at "accept" time, it's really about 20 seconds for each line. When
the server says "HELLO\r\n", the client takes 20 seconds until it returns
from "gets" with that line.

In my eyes, this sounds like a timeout issue - only when a timeout occurs,
the "gets" returns.

I read about a patch needed for 1.8.1 about nonblocking connect() somewhere
in the INet, but it did not sound as if it helps for my gets() problem.

What I did find out in the meantime: this only happens if the server task
runs on my NT4 machine - another machine (Win2K) reacts fast. So I guess I
can run the server task on a different machine and be happy. Yet I'd like to
know the reason...

Christian


Kero van Gelder

1/15/2005 10:24:00 AM

0

> It's not at "accept" time, it's really about 20 seconds for each line. When
> the server says "HELLO\r\n", the client takes 20 seconds until it returns
> from "gets" with that line.

TCP does some timeout stuff, so actively talking in both directions gives
you slow throughput on remote machines. I've seen 25 exchanges
per second, typically (Linux, HP-UX).

But 20 seconds sounds... broken... Try other progamming languages on the
suspect machine or a reinstall of the OS (it is windows, you say below; I
don't run windows, and I don't know about this particular flavour.)

> In my eyes, this sounds like a timeout issue - only when a timeout occurs,
> the "gets" returns.
>
> I read about a patch needed for 1.8.1 about nonblocking connect() somewhere
> in the INet, but it did not sound as if it helps for my gets() problem.
>
> What I did find out in the meantime: this only happens if the server task
> runs on my NT4 machine - another machine (Win2K) reacts fast. So I guess I
> can run the server task on a different machine and be happy. Yet I'd like to
> know the reason...

You may want to try the TCP_NODELAY option (that's what got me above the
25 exchanges per seconds).

--

wanna keep developing software?
http://swpat...

+--- Kero ----------------------- kero@chello@nl ---+
| all the meaningless and empty words I spoke |
| Promises -- The Cranberries |
+--- M38c --- http://httpd.chello.nl/k... ---+