15 #include <nanomsg/nn.h> 16 #include <nanomsg/reqrep.h> 19 #define SOCKET_ADDRESS "inproc://test" 24 data_length = strlen(data);
26 bytes = nn_recv(sock, &buf, NN_MSG, 0);
27 printf (
"Socket %d EXPECTED %s RECEIVED %s [%d bytes]\n", sock, data, (
char*)buf, bytes);
43 rep1 = nn_socket (AF_SP, NN_REP);
45 req1 = nn_socket (AF_SP, NN_REQ);
47 req2 = nn_socket (AF_SP, NN_REQ);
51 rc = nn_send (rep1,
"ABC", 3, 0);
53 rc = nn_recv (req1, buf,
sizeof (buf), 0);
57 nn_send (req2,
"ABC", 3, 0);
59 nn_send (rep1,
"ABC", 3, 0);
62 nn_send (req1,
"ABC", 3, 0);
64 nn_send (rep1,
"ABC", 3, 0);
72 req1 = nn_socket (AF_SP, NN_REQ);
74 rep1 = nn_socket (AF_SP, NN_REP);
76 rep2 = nn_socket (AF_SP, NN_REP);
79 nn_send (req1,
"ABC", 3, 0);
81 nn_send (rep1,
"ABC", 3, 0);
84 nn_send (req1,
"ABC", 3, 0);
86 nn_send (rep2,
"ABC", 3, 0);
94 rep1 = nn_socket (AF_SP, NN_REP);
96 req1 = nn_socket (AF_SP, NN_REQ);
99 rc = nn_setsockopt (req1, NN_REQ, NN_REQ_RESEND_IVL,
100 &resend_ivl,
sizeof (resend_ivl));
102 nn_send (req1,
"ABC", 3, 0);
113 req1 = nn_socket (AF_SP, NN_REQ);
115 nn_send (req1,
"ABC", 3, 0);
117 rep1 = nn_socket (AF_SP, NN_REP);
120 rc = nn_setsockopt (rep1, NN_SOL_SOCKET, NN_RCVTIMEO,
121 &timeo,
sizeof (timeo));
129 req1 = nn_socket (AF_SP, NN_REQ);
131 rep1 = nn_socket (AF_SP, NN_REP);
133 rep2 = nn_socket (AF_SP, NN_REP);
137 rc = nn_setsockopt (rep1, NN_SOL_SOCKET, NN_RCVTIMEO,
138 &timeo,
sizeof (timeo));
139 rc = nn_setsockopt (rep2, NN_SOL_SOCKET, NN_RCVTIMEO,
140 &timeo,
sizeof (timeo));
142 nn_send (req1,
"ABC", 3, 0);
150 nn_send (rep2,
"REPLY", 5, 0);
159 req1 = nn_socket (AF_SP, NN_REQ);
161 nn_send (req1,
"ABC", 3, 0);
162 nn_send (req1,
"DEF", 3, 0);
164 rep1 = nn_socket (AF_SP, NN_REP);
void test_recv(int sock, const char *data)