Thank you very much! I guess I understand you. But my last question is that can I use server's PUB socket to call zmq_recv() to process the queued commands. In ZMQ docs, it is said that PUB socket is only used to send data. So, is it conflicting?
2011/7/22 Martin Sustrik <[email protected]> > On 07/22/2011 04:33 AM, yy l wrote: > > But I have closed the socket every time after connecting server. So, >> when client close socket, is it mean that it actively shutdown >> connection, and does server know client's socket closing, and what's >> server's reaction, will it release the resource of machine? >> > > Yes, the server will release associated resources. > > The problem in your case are the resources owned by the application thread. > > When connection/disconnection happens, I/O thread sends an internal message > (a.k.a. command) to you thread to notify it about the event. Given that your > test program never calls libzmq, it has no opportunity to process the > command. Thus, the command is queued for processing later. > > In the long run the queued commands will fill the pipe they are passed > through (socketpair). In new versions of 0mq, the commands are stored in > memory rather than in sockepair buffers, which allows for more commands to > be queued, but given that your application thread never passes control to > libzmq, it'll fail ultimately once it exhausts all the memory. > > The right way to handle this is to have an even loop in the server > application, say based on zmq_poll, or maybe just doing zmq_recv. > > Martin >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
