Buffer in TCPSocket when communicating via 127.0.0.1?

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!

On Thu, May 17, 2007 at 12:43:13AM +0900, Felipe N. 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

Felipe N. 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.