Re: [zeromq-dev] STREAM socket not closing.
To use a ZMQ_STREAM socket as client, you have to fetch its identity after connecting. It's not entirely intuitive, e.g.: void *client = zmq_socket (ctx, ZMQ_STREAM); zmq_connect (client, tcp://localhost:9080); uint8_t id [256]; size_t id_size = 256; zmq_getsockopt (client, ZMQ_IDENTITY, id, id_size); zmq_send (client, id, id_size, ZMQ_SNDMORE); zmq_send (client, GET /\n\n, 7, 0); On Fri, Jan 10, 2014 at 9:55 AM, Laurent Alebarde l.aleba...@free.fr wrote: Le 10/01/2014 07:10, Matt Connolly a écrit : Dear list, I’m looking at using the STREAM socket to interface with some plain old TCP clients, however, there seems to be two things I’m missing: 1. How do I send a message to a client first? Once the client sends a message I can get the identity frame and use that to reply. How do I send a message before receiving any data? ZMQ_STREAM is like ROUTER. In my understanding and small experience, you cannot. 2. Closing sockets. I see in the docs that a socket can be closed by sending the identity frame followed by a zero length frame. However, this does not seem to be working. I’m expecting to successfully read 0 bytes from the TCP socket meaning that the connection was actively closed, and no error codes. Instead by TCP socket recv blocks forever. The only way I can get this to happen is to close the ZMQ socket, which is not possible when I am using bind and talking to multiple TCP clients. Cheers, Matt ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] STREAM socket not closing.
Le 10/01/2014 07:10, Matt Connolly a écrit : Dear list, I’m looking at using the STREAM socket to interface with some plain old TCP clients, however, there seems to be two things I’m missing: 1. How do I send a message to a client first? Once the client sends a message I can get the identity frame and use that to reply. How do I send a message before receiving any data? ZMQ_STREAM is like ROUTER. In my understanding and small experience, you cannot. 2. Closing sockets. I see in the docs that a socket can be closed by sending the identity frame followed by a zero length frame. However, this does not seem to be working. I’m expecting to successfully read 0 bytes from the TCP socket meaning that the connection was actively closed, and no error codes. Instead by TCP socket recv blocks forever. The only way I can get this to happen is to close the ZMQ socket, which is not possible when I am using bind and talking to multiple TCP clients. Cheers, Matt ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] STREAM socket not closing.
Dear list, I’m looking at using the STREAM socket to interface with some plain old TCP clients, however, there seems to be two things I’m missing: 1. How do I send a message to a client first? Once the client sends a message I can get the identity frame and use that to reply. How do I send a message before receiving any data? 2. Closing sockets. I see in the docs that a socket can be closed by sending the identity frame followed by a zero length frame. However, this does not seem to be working. I’m expecting to successfully read 0 bytes from the TCP socket meaning that the connection was actively closed, and no error codes. Instead by TCP socket recv blocks forever. The only way I can get this to happen is to close the ZMQ socket, which is not possible when I am using bind and talking to multiple TCP clients. Cheers, Matt ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev