-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with unix domain sockets #11
Comments
On Thu, Sep 05, 2013 at 11:14:07AM -0700, PatrickCosmo wrote:
It looks as if you've done everything right from the client side but it's This might happen if the server is waiting for the client to send You can check by strace'ing the server process. If it is reading the |
Thanks Michael, Date: Thu, 5 Sep 2013 13:51:05 -0700 On Thu, Sep 05, 2013 at 11:14:07AM -0700, PatrickCosmo wrote:
It looks as if you've done everything right from the client side but it's hard to say without knowing more about the server. This might happen if the server is waiting for the client to send a complete message. For example, the message format prefaces the packet with a length and the server is blocking in read(), waiting for N bytes. Or the server is waiting for some bytes to indicate an end of message. When the client calls close(), the server's read() returns and the server continues processing the data. You can check by strace'ing the server process. If it is reading the data you are sending from the client, then it's possible the client is sending a packet that is malformed in some way. — |
On Fri, Sep 06, 2013 at 06:29:52AM -0700, PatrickCosmo wrote:
Definitely would not rule out a bug in procket. Are the other clients sending a linefeed character or other EOL
Sure, that would be great.
Doubt it is a problem with the service.
One thing you can try: print out the data you're sending in hex in one |
You're correct, adding an '\n' fixed it. Eesh. Sometimes the most obvious things ... On 2013-09-06, at 11:06 AM, "Michael Santos" [email protected] wrote:
|
On Fri, Sep 06, 2013 at 08:08:55AM -0700, PatrickCosmo wrote:
Don't know how many times I've forgotten the '\n'. Glad it works! Let me |
I'm using procket to communicate with a server using unix domain sockets. I can connect to the service and write data to the socket, but the data is never sent until I close the socket.
If I'm only sending a one-way message to the service, this works beautifully.
But if I need to get a response from the service, I can't make it happen: the data never sends until I close the socket, and once the socket is closed of course I cannot get a reply.
Here is my code, simplified:
initSocket(SocketFile) ->
Len = byte_size(SocketFile),
UnixDomainSocket = <<( procket:sockaddr_common(?PF_LOCAL, Len))/binary,
SocketFile/binary,
0:((procket:unix_path_max()-Len)*8)
>>,
UnixDomainSocket.
sendData(SocketFile, Data) ->
{ok, Socket} = procket:socket(?PF_LOCAL, ?SOCK_STREAM, 0),
UnixSocket = initSocket(SocketFile),
Result = procket:connect(Socket, UnixSocket),
case Result of
ok ->
WriteResult = procket:write(Socket, Data),
at the above point, no data is sent, and it won't be sent until I call
procket:close(Socket).
calling procket:read(Socket, DataSize) does nothing of course, I never get a response from the service bc it hasn't received my request.
Any ideas?
The text was updated successfully, but these errors were encountered: