[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Buffer in TCPSocket when communicating via 127.0.0.1?

Felipe Navas

5/16/2007 3:43:00 PM

I'm using the TCPSocket.send, TCPSocket.gets and TCPSocket.gets to
make communication between a ruby script and a C program in Linux. I'm
experiencing some troubles with synchronization and lag.
There is no problem with the C program; it's working fine.

There is any buffer in TCPSocket when communicating via 127.0.0.1?
Where I can read anything about this ?

Thanx!

--
(.) CAMPANHA DA FITA ASCII ( http://ar...)
/ \ Contra formatos proprietarios

2 Answers

Brian Candler

5/16/2007 5:21:00 PM

0

On Thu, May 17, 2007 at 12:43:13AM +0900, Felipe Navas wrote:
> I'm using the TCPSocket.send, TCPSocket.gets and TCPSocket.gets to
> make communication between a ruby script and a C program in Linux. I'm
> experiencing some troubles with synchronization and lag.
> There is no problem with the C program; it's working fine.
>
> There is any buffer in TCPSocket when communicating via 127.0.0.1?
> Where I can read anything about this ?

Can you describe your symptoms more accurately?

If you are seeing a delay of 100ms before a packet is sent, then you are
probably hitting the Nagle algorithm in the kernel. You can setsockopt
TCP_NODELAY to turn it off.

Also look at IO#sync=true

Joel VanderWerf

5/17/2007 5:24:00 AM

0

Felipe Navas wrote:
> I'm using the TCPSocket.send, TCPSocket.gets and TCPSocket.gets to
> make communication between a ruby script and a C program in Linux. I'm
> experiencing some troubles with synchronization and lag.
> There is no problem with the C program; it's working fine.
>
> There is any buffer in TCPSocket when communicating via 127.0.0.1?
> Where I can read anything about this ?

You might want to be using TCPSocket#recv instead of #gets. IIRC, the
latter adds a layer of buffering.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407