void device1 (NN_UNUSED void *arg) { int rc; int deva; int devb; /* Intialise the device sockets. */ deva = test_socket (AF_SP_RAW, NN_PAIR); test_bind (deva, SOCKET_ADDRESS_A); devb = test_socket (AF_SP_RAW, NN_PAIR); test_bind (devb, SOCKET_ADDRESS_B); /* Run the device. */ rc = nn_device (deva, devb); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (devb); test_close (deva); }
void device2 (NN_UNUSED void *arg) { int rc; int devc; int devd; /* Intialise the device sockets. */ devc = test_socket (AF_SP_RAW, NN_PULL); test_bind (devc, SOCKET_ADDRESS_C); devd = test_socket (AF_SP_RAW, NN_PUSH); test_bind (devd, SOCKET_ADDRESS_D); /* Run the device. */ rc = nn_device (devc, devd); nn_assert (rc < 0 && nn_errno () == EBADF); /* Clean up. */ test_close (devd); test_close (devc); }
void device5 (NN_UNUSED void *arg) { int rc; int dev0; int dev1; /* Intialise the device sockets. */ dev0 = test_socket (AF_SP_RAW, NN_REP); test_bind (dev0, socket_address_h); dev1 = test_socket (AF_SP_RAW, NN_REQ); test_bind (dev1, socket_address_i); /* Run the device. */ rc = nn_device (dev0, dev1); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (dev0); test_close (dev1); }
int main (int argc, char **argv) { int sock1, sock2; int rc; nn_options_t options = { /* verbose */ 0, /* protocol */ 0, /* topology */ NULL, }; nn_parse_options (&nn_cli, &options, argc, argv); sock1 = nn_create_socket1 (&options); nn_connect_socket (&options, sock1); sock2 = nn_create_socket2 (&options); if(sock2 >= 0) nn_connect_socket (&options, sock2); rc = nn_device (sock1, sock2); nn_assert_errno (rc >= 0, "Failed to start device"); nc_close (sock2); nc_close (sock1); return 0; }
void device(socket &s1, socket &s2) { nn_device(s1.fd(), s2.fd()); throw_error(); }