Pergunta

I have a program (Python) that in some point uses

    zmq.Context.socket(zmq.REP)

and

    zmq.Context.socket(zmq.PAIR) 

sockets but the problem is that when program is killed the sockets still can be found using:

    'ps aux | grep zmq'

command. So what can I do to make them disappear after program is killed?

Foi útil?

Solução

According to;

https://superuser.com/questions/127863/manually-closing-a-port-from-commandline

Only an application can close the sockets it is using, after the applications process is killed, the sockets should be automatically freed within a couple of minutes. Are you being patient enough?

Outras dicas

You can use SO_REUSEADDR to work around that problem

SO_REUSEADDR Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For AF_INET sockets this means that a socket may bind except when there is an active listening socket bound to the address. When the listen- ing socket is bound to INADDR_ANY with a specific port then it is not possible to bind to this port for any local address. Argument is an integer boolean flag.

This should anser most of your questions http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top