Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
f9188841
Commit
f9188841
authored
Sep 04, 2013
by
Sebastien Pierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarified zmq_socket.txt ZMQ_STREAM section, added example
parent
ef207e45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
2 deletions
+43
-2
zmq_socket.txt
doc/zmq_socket.txt
+43
-2
No files found.
doc/zmq_socket.txt
View file @
f9188841
...
@@ -347,12 +347,15 @@ routed to, and unroutable messages shall cause an EHOSTUNREACH or EAGAIN error.
...
@@ -347,12 +347,15 @@ routed to, and unroutable messages shall cause an EHOSTUNREACH or EAGAIN error.
To open a connection to a server, use the zmq_connect call, and then fetch the
To open a connection to a server, use the zmq_connect call, and then fetch the
socket identity using the ZMQ_IDENTITY zmq_getsockopt call.
socket identity using the ZMQ_IDENTITY zmq_getsockopt call.
To close a specific client connection, as a server, send
a zero-length message
To close a specific client connection, as a server, send
the identity frame
follow
ing the identity frame
.
follow
ed by a zero-length message (see EXAMPLE section)
.
The ZMQ_MSGMORE flag is ignored on data frames. You must send one identity frame
The ZMQ_MSGMORE flag is ignored on data frames. You must send one identity frame
followed by one data frame.
followed by one data frame.
Also, please note that omitting the ZMQ_MSGMORE flag will prevent sending further
data (from any client) on the same socket.
[horizontal]
[horizontal]
.Summary of ZMQ_STREAM characteristics
.Summary of ZMQ_STREAM characteristics
Compatible peer sockets:: none.
Compatible peer sockets:: none.
...
@@ -381,6 +384,44 @@ The limit on the total number of open 0MQ sockets has been reached.
...
@@ -381,6 +384,44 @@ The limit on the total number of open 0MQ sockets has been reached.
*ETERM*::
*ETERM*::
The context specified was terminated.
The context specified was terminated.
EXAMPLE
-------
.Creating a simple HTTP server using ZMQ_STREAM
----
void *ctx = zmq_ctx_new ();
assert (ctx);
/* Create ZMQ_STREAM socket */
void *socket = zmq_socket (ctx, ZMQ_STREAM);
assert (socket);
int rc = zmq_bind (socket, "tcp://*:8080");
assert (rc == 0);
/* Data structure to hold the ZMQ_STREAM ID */
uint8_t id [256];
size_t id_size = 256;
while (1) {
/* Get HTTP request; ID frame and then request */
id_size = zmq_recv (server, id, 256, 0);
assert (id_size > 0);
/* Prepares the response */
char http_response [] =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"Hello, World!";
/* Sends the ID frame followed by the response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
zmq_send (socket, http_response, strlen (http_response), ZMQ_SNDMORE);
/* Closes the connection by sending the ID frame followed by a zero response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
zmq_send (socket, 0, 0, ZMQ_SNDMORE);
/* NOTE: If we don't use ZMQ_SNDMORE, then we won't be able to send more */
/* message to any client */
}
zmq_close (socket);
zmq_ctx_destroy (ctx);
----
SEE ALSO
SEE ALSO
--------
--------
linkzmq:zmq_init[3]
linkzmq:zmq_init[3]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment