Commit f0a34e0f authored by Luca Boccassi's avatar Luca Boccassi

Problem: test_poller/use_fd_ipc/tcp use draft API

Solution: only use ZMQ_SERVER/CLIENT if the defines are available.
parent c293618a
...@@ -50,6 +50,7 @@ int main (void) ...@@ -50,6 +50,7 @@ int main (void)
void *bowl = zmq_socket (ctx, ZMQ_PULL); void *bowl = zmq_socket (ctx, ZMQ_PULL);
assert (bowl); assert (bowl);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *server = zmq_socket (ctx, ZMQ_SERVER); void *server = zmq_socket (ctx, ZMQ_SERVER);
assert (server); assert (server);
rc = zmq_bind (server, "tcp://127.0.0.1:55557"); rc = zmq_bind (server, "tcp://127.0.0.1:55557");
...@@ -57,6 +58,7 @@ int main (void) ...@@ -57,6 +58,7 @@ int main (void)
void *client = zmq_socket (ctx, ZMQ_CLIENT); void *client = zmq_socket (ctx, ZMQ_CLIENT);
assert (client); assert (client);
#endif
// Set up poller // Set up poller
void* poller = zmq_poller_new (); void* poller = zmq_poller_new ();
...@@ -116,6 +118,7 @@ int main (void) ...@@ -116,6 +118,7 @@ int main (void)
assert (event.user_data == bowl); assert (event.user_data == bowl);
zmq_poller_remove_fd (poller, fd); zmq_poller_remove_fd (poller, fd);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
// Polling on thread safe sockets // Polling on thread safe sockets
rc = zmq_poller_add (poller, server, NULL, ZMQ_POLLIN); rc = zmq_poller_add (poller, server, NULL, ZMQ_POLLIN);
assert (rc == 0); assert (rc == 0);
...@@ -138,6 +141,7 @@ int main (void) ...@@ -138,6 +141,7 @@ int main (void)
assert (event.socket == server); assert (event.socket == server);
assert (event.user_data == NULL); assert (event.user_data == NULL);
assert (event.events == ZMQ_POLLOUT); assert (event.events == ZMQ_POLLOUT);
#endif
// Destory poller, sockets and ctx // Destory poller, sockets and ctx
rc = zmq_poller_destroy (&poller); rc = zmq_poller_destroy (&poller);
...@@ -148,10 +152,12 @@ int main (void) ...@@ -148,10 +152,12 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (bowl); rc = zmq_close (bowl);
assert (rc == 0); assert (rc == 0);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
rc = zmq_close (server); rc = zmq_close (server);
assert (rc == 0); assert (rc == 0);
rc = zmq_close (client); rc = zmq_close (client);
assert (rc == 0); assert (rc == 0);
#endif
rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
......
...@@ -124,6 +124,7 @@ void test_pair () ...@@ -124,6 +124,7 @@ void test_pair ()
void test_client_server () void test_client_server ()
{ {
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *ctx = zmq_ctx_new (); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
...@@ -200,6 +201,7 @@ void test_client_server () ...@@ -200,6 +201,7 @@ void test_client_server ()
rc = unlink ("/tmp/tester"); rc = unlink ("/tmp/tester");
assert (rc == 0); assert (rc == 0);
#endif
} }
int main (void) int main (void)
......
...@@ -130,6 +130,7 @@ void test_pair () ...@@ -130,6 +130,7 @@ void test_pair ()
void test_client_server () void test_client_server ()
{ {
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *ctx = zmq_ctx_new (); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
...@@ -203,6 +204,7 @@ void test_client_server () ...@@ -203,6 +204,7 @@ void test_client_server ()
rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
#endif
} }
int main (void) int main (void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment