45 #define CONTENT_SIZE 13 46 #define CONTENT_SIZE_MAX 32 48 #define ID_SIZE_MAX 32 73 sprintf (identity,
"%04X-%04X", rand() % 0xFFFF, rand() % 0xFFFF);
88 for (centitick = 0; centitick < 20; centitick++) {
92 size_t sz =
sizeof (rcvmore);
95 if (
is_verbose) printf(
"client receive - identity = %s content = %s\n", identity, content);
97 assert (memcmp (content,
"request #", 9) == 0);
102 if (items [1].revents & ZMQ_POLLIN) {
104 if (
is_verbose) printf(
"client receive - identity = %s command = %s\n", identity, content);
105 if (memcmp (content,
"TERMINATE", 9) == 0) {
111 sprintf(content,
"request #%03d", ++request_nbr);
139 rc =
zmq_bind (frontend,
"tcp://127.0.0.1:5563");
147 rc =
zmq_bind (backend,
"inproc://backend");
163 for (thread_nbr = 0; thread_nbr <
QT_WORKERS; thread_nbr++)
170 for (thread_nbr = 0; thread_nbr <
QT_WORKERS; thread_nbr++)
214 printf(
"server_worker receives command = %s\n", content);
215 if (memcmp (content,
"TERMINATE", 9) == 0)
225 printf (
"server receive - identity = %s content = %s\n", identity, content);
228 int reply, replies = rand() % 5;
229 for (reply = 0; reply < replies; reply++) {
231 msleep (rand () % 10 + 1);
261 rc =
zmq_bind (control,
"inproc://control");
270 rc =
zmq_send (control,
"TERMINATE", 9, 0);
276 for (
int i = 0; i < QT_CLIENTS + 1; i++)
void msleep(int milliseconds)
ZMQ_EXPORT int zmq_setsockopt(void *s, int option, const void *optval, size_t optvallen)
void server_task(void *ctx)
ZMQ_EXPORT void * zmq_ctx_new(void)
static void client_task(void *ctx)
void setup_test_environment(void)
ZMQ_EXPORT int zmq_recv(void *s, void *buf, size_t len, int flags)
static void worker(void *s)
ZMQ_EXPORT void * zmq_socket(void *, int type)
ZMQ_EXPORT void zmq_threadclose(void *thread)
static void server_worker(void *ctx)
ZMQ_EXPORT int zmq_getsockopt(void *s, int option, void *optval, size_t *optvallen)
ZMQ_EXPORT int zmq_connect(void *s, const char *addr)
ZMQ_EXPORT int zmq_close(void *s)
ZMQ_EXPORT int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout)
ZMQ_EXPORT int zmq_send(void *s, const void *buf, size_t len, int flags)
ZMQ_EXPORT int zmq_bind(void *s, const char *addr)
ZMQ_EXPORT int zmq_ctx_term(void *context)
ZMQ_EXPORT void * zmq_threadstart(zmq_thread_fn *func, void *arg)
ZMQ_EXPORT int zmq_proxy_steerable(void *frontend, void *backend, void *capture, void *control)