We can set socket options using setsockopt on BasicSocket, where can I
get
various constants SOL_ constants such as Socket::SOL_SOCKET etc?
I am unable to find them in rdoc.
Also while writing a TCP client to a non Ruby (but non blocking) server
while I write on the socket using socket.write I am not getting
anything on the server till I do socket.close.
socket.puts works fine but has an additional newline in the
message
which I do not want.
Any pointers in both of these questions will be greatly appreciated.
Also while writing a TCP client to a non Ruby (but non blocking)
server
while I write on the socket using socket.write I am not
getting
anything on the server till I do socket.close.
socket.puts works fine but has an additional newline in
the message
which I do not want.
Try socket.flush. It seems like your socket is line buffered. I’m not
sure how Ruby decides on buffering and there doesn’t seem to be an
interface to something like setvbuf. Perhaps someone else can provide
some insight.
One thing to keep in mind when using TCP is that message boundaries
are not preserved. A write on one end of a TCP socket does not
necessarily
map to a corresponding read with the same data on the other
end of the socket.
We can set socket options using setsockopt on BasicSocket, where can I get
various constants SOL_ constants such as Socket::SOL_SOCKET etc?
I am unable to find them in rdoc.
I am afraid, RDoc won’t have an exhaustive list of these constants.
However, for all such purposes, I have Richard Stevens book on network
programming book and you can find them listed there.
Also while writing a TCP client to a non Ruby (but non blocking) server
while I write on the socket using socket.write I am not getting
anything on the server till I do socket.close.
socket.puts works fine but has an additional newline in the message
which I do not want.
Also problem you mention shouldn’t have anything to do with flush or
naggle algorithm.
Probably, your server is using newline as message separator in which
case. But this is just a wild guess.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.