Buffer in TCPSocket when communicating via 127.0.0.1?

F

Felipe Navas

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!
 
B

Brian Candler

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
 
J

Joel VanderWerf

Felipe said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top