How to check if the connection is still open?
Issue #3
wontfix
Hi Kaspar,
I discovered this library today and it looks quite simple and easy to use from the ruby interface. However, I would like to check for messages until the connection drops. Now, I dont see a method which can give me the status of the connection. Is there probably a workaround?
As code, I would like to implement something like this:
sock = NanoMsg::PairSocket.new
sock.connect("ipc:///tmp/myendpoint.ipc")
while(sock.is_open)
res=sock.recv
...process res....
end
Thanks a lot in advance!
Eugen
Comments (3)
-
reporter -
repo owner AFAIK, you cannot explicitly test nanomsg sockets for 'open?' - and so the library cannot either.
You can use all setsockopts; for example this should work:
@q.setsockopt(NanoMsg::NN_SOL_SOCKET, NanoMsg::NN_RCVTIMEO, 5000)
-
repo owner - changed status to wontfix
This was more of a question. I think the answer is sufficient and the library is fine, really.
- Log in to comment
My current work around is now like this:
However, I have not found the constants I am passing to the setsockop function. Is it possible to use something like NanoMsg::NN_SOL_SOCKET and NanoMsg::NN_RCVTIMEO ?