Help with UNIX sockets

This is the place for queries that don't fit in any of the other categories.

Help with UNIX sockets

Postby icblnk » Sun May 12, 2013 2:40 am

Hello.
I am experiencing some problems with receiving information via a unix socket. I have the following code:
Code: Select all
import socket

print "Connecting..."
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect("/path/to/socket/file.sock")
client.settimeout(5)
print "Ready"
try:
    client.send("l")
except socket.error, why:
    raise why
try:
    data = client.recv(1024)
except socket.error, why:
    raise why
print "received message: ", data
client.close()
print "Done"


It just gets stuck on the line "data = client.recv(1024)" and as i understand it waits for data to receive, but there is no data comes.

When i use netcat, it works ok:

Code: Select all
nc -U /path/to/socket/file.sock
l
Total: 0 #information i'm trying to receive


I hope someone can help me and thanks in advance!
icblnk
 
Posts: 1
Joined: Sun May 12, 2013 2:26 am

Return to General Coding Help

Who is online

Users browsing this forum: pythonista, snippsat and 3 guests