Skip to content
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

connection timeout #72

Open
hamzehnasajpour opened this issue Feb 19, 2019 · 6 comments
Open

connection timeout #72

hamzehnasajpour opened this issue Feb 19, 2019 · 6 comments

Comments

@hamzehnasajpour
Copy link

After creating a socket, how can I find out that the connection path is available or not? Please see the following codes, assume that path isn't available. How can I detect it after s1.connect(path)?

s1 = Socket(PUSH)
s1.connect(path)
s1.send(makeCapnpPacket().to_bytes())
@tonysimpson
Copy link
Owner

connect returns an endpoint object that has an address attribute

e1 = s1.connect(path) e1.address
all endpoints are also available as a list on the socket

s1.endpoints

@hamzehnasajpour
Copy link
Author

My m
My main problem is that ipc_path = "ipc://test" isn't available, and no body listen to it, how can I detect that ipc_path is available and I could connect it successfully.

ipc_path = "ipc://test"
s1 = Socket(PUSH)
s1.connect(ipc_path)

@tonysimpson
Copy link
Owner

Ok I see a problem. Testing between process on ubuntu 18.10 with libnanomsg version 0.8~beta+dfsg-1 (that's very old?) I can't connect between the two using 'ipc://test' - lsof shows two separate unix sockets called test. using 'ipc:///tmp/test' work fine.

Is this the same issue you are having?

@hamzehnasajpour
Copy link
Author

Sorry, This is an misunderstanding. One process(server) listen to a Unix Socket, and another process(client) can connect to it by this socket. If the server does not exist so there is no Unix Socket (ipc_path) so when my client connect to it, how can I detect that this path is available or not? How can I detect that I can send data to it or the server not available?

@tonysimpson
Copy link
Owner

Ah Ok. Depends on your use case I guess. But if you just want to exit the client if the server is not there you could set a socket timeout with recv_timeout? But I've just tried it and it seems broken. What are your OS, Python version and architecture (x86_64?)?

@hamzehnasajpour
Copy link
Author

Sorry for late reply.
I'm using Ubuntu 18.04 (x86_64) with Python2.7.

How can I change the socket timeout for recv or send?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants