0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

Problem: test_poller/use_fd_ipc/tcp use draft API

Solution: only use ZMQ_SERVER/CLIENT if the defines are available.
This commit is contained in:
Luca Boccassi 2016-05-02 19:40:30 +01:00
parent c293618ae8
commit f0a34e0ff5
3 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,7 @@ int main (void)
void *bowl = zmq_socket (ctx, ZMQ_PULL);
assert (bowl);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *server = zmq_socket (ctx, ZMQ_SERVER);
assert (server);
rc = zmq_bind (server, "tcp://127.0.0.1:55557");
@ -57,6 +58,7 @@ int main (void)
void *client = zmq_socket (ctx, ZMQ_CLIENT);
assert (client);
#endif
// Set up poller
void* poller = zmq_poller_new ();
@ -116,6 +118,7 @@ int main (void)
assert (event.user_data == bowl);
zmq_poller_remove_fd (poller, fd);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
// Polling on thread safe sockets
rc = zmq_poller_add (poller, server, NULL, ZMQ_POLLIN);
assert (rc == 0);
@ -138,6 +141,7 @@ int main (void)
assert (event.socket == server);
assert (event.user_data == NULL);
assert (event.events == ZMQ_POLLOUT);
#endif
// Destory poller, sockets and ctx
rc = zmq_poller_destroy (&poller);
@ -148,10 +152,12 @@ int main (void)
assert (rc == 0);
rc = zmq_close (bowl);
assert (rc == 0);
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
rc = zmq_close (server);
assert (rc == 0);
rc = zmq_close (client);
assert (rc == 0);
#endif
rc = zmq_ctx_term (ctx);
assert (rc == 0);

View File

@ -124,6 +124,7 @@ void test_pair ()
void test_client_server ()
{
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *ctx = zmq_ctx_new ();
assert (ctx);
@ -200,6 +201,7 @@ void test_client_server ()
rc = unlink ("/tmp/tester");
assert (rc == 0);
#endif
}
int main (void)

View File

@ -130,6 +130,7 @@ void test_pair ()
void test_client_server ()
{
#if defined(ZMQ_SERVER) && defined(ZMQ_CLIENT)
void *ctx = zmq_ctx_new ();
assert (ctx);
@ -203,6 +204,7 @@ void test_client_server ()
rc = zmq_ctx_term (ctx);
assert (rc == 0);
#endif
}
int main (void)