From: Ryan Pavlik Date: 2003-04-04T06:06:15+09:00 Subject: Clarification: read/write slow, and TCPSocket and sys{read,write} On Fri, 4 Apr 2003 05:48:53 +0900 Ryan Pavlik wrote: > For instance, I can marshal and send 1000 objects, and receive 1000 > replies, in a fraction of a second. However, if I send them one-by-one, > it takes minutes! Same code on both ends for the test. What gets sent > is a 4-byte network-order length, followed by the data. I hate replying to myself, but I should clarify. They are always sent and handled one-by-one. Send an object, the server handles and object, and sends the reply. The slow part is when I send the object, get the reply, send the object, get the reply, etc. If I send 1000 objects in a row and then read the 1000 replies, it's fast. But they're always sent and handled individually. A little pseudocode to help: Fast: (1..1000).each { connection.send(Ping.new) } (1..1000).each { pong = connection.get } Slow: (1..1000).each { connection.send(Ping.new) pong = connection.get } I hope that's clearer. :-) -- Ryan Pavlik "I've got a crude stabbing implement right here with your name all over it." - 8BT