2015-11-13 10:41:00 +01:00
|
|
|
#include "testutil.hpp"
|
|
|
|
|
|
|
|
void test_setsockopt_tcp_recv_buffer()
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
void *ctx = zmq_ctx_new();
|
|
|
|
void *socket = zmq_socket(ctx, ZMQ_PUSH);
|
|
|
|
|
|
|
|
int val = 0;
|
|
|
|
size_t placeholder = sizeof(val);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
rc = zmq_setsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, sizeof(val));
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
val = 16384;
|
|
|
|
|
|
|
|
rc = zmq_setsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, sizeof(val));
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 16384);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 16384);
|
|
|
|
|
|
|
|
zmq_close(socket);
|
|
|
|
zmq_ctx_term(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_setsockopt_tcp_send_buffer()
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
void *ctx = zmq_ctx_new();
|
|
|
|
void *socket = zmq_socket(ctx, ZMQ_PUSH);
|
|
|
|
|
|
|
|
int val = 0;
|
|
|
|
size_t placeholder = sizeof(val);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_SEND_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
rc = zmq_setsockopt(socket, ZMQ_TCP_SEND_BUFFER, &val, sizeof(val));
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_SEND_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 8192);
|
|
|
|
|
|
|
|
val = 16384;
|
|
|
|
|
|
|
|
rc = zmq_setsockopt(socket, ZMQ_TCP_SEND_BUFFER, &val, sizeof(val));
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 16384);
|
|
|
|
|
|
|
|
rc = zmq_getsockopt(socket, ZMQ_TCP_SEND_BUFFER, &val, &placeholder);
|
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 16384);
|
|
|
|
|
|
|
|
zmq_close(socket);
|
|
|
|
zmq_ctx_term(ctx);
|
|
|
|
}
|
|
|
|
|
2016-02-09 09:36:14 +00:00
|
|
|
void test_setsockopt_use_fd()
|
2016-02-01 12:00:45 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
void *ctx = zmq_ctx_new();
|
|
|
|
void *socket = zmq_socket(ctx, ZMQ_PUSH);
|
|
|
|
|
|
|
|
int val = 0;
|
|
|
|
size_t placeholder = sizeof(val);
|
|
|
|
|
2016-02-09 09:36:14 +00:00
|
|
|
rc = zmq_getsockopt(socket, ZMQ_USE_FD, &val, &placeholder);
|
2016-02-01 12:00:45 +00:00
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == -1);
|
|
|
|
|
|
|
|
val = 3;
|
|
|
|
|
2016-02-09 09:36:14 +00:00
|
|
|
rc = zmq_setsockopt(socket, ZMQ_USE_FD, &val, sizeof(val));
|
2016-02-01 12:00:45 +00:00
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 3);
|
|
|
|
|
2016-02-09 09:36:14 +00:00
|
|
|
rc = zmq_getsockopt(socket, ZMQ_USE_FD, &val, &placeholder);
|
2016-02-01 12:00:45 +00:00
|
|
|
assert(rc == 0);
|
|
|
|
assert(val == 3);
|
|
|
|
|
|
|
|
zmq_close(socket);
|
|
|
|
zmq_ctx_term(ctx);
|
|
|
|
}
|
|
|
|
|
2015-11-13 10:41:00 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test_setsockopt_tcp_recv_buffer();
|
|
|
|
test_setsockopt_tcp_send_buffer();
|
2016-02-09 09:36:14 +00:00
|
|
|
test_setsockopt_use_fd();
|
2015-11-13 10:41:00 +01:00
|
|
|
}
|