int _tmain(int argc, _TCHAR* argv[]) { HMODULE hDll = ::LoadLibrary(L"circe_client_network.dll"); assert(hDll); if (hDll) { p_circe_client_network_version = (pf_circe_client_network_version)::GetProcAddress(hDll, "circe_client_network_version"); p_circe_client_network_interface = (pf_circe_client_network_interface)::GetProcAddress(hDll, "circe_client_network_interface"); assert(p_circe_client_network_version && p_circe_client_network_interface); if (p_circe_client_network_version && p_circe_client_network_interface) { printf("ver=%ld\n", p_circe_client_network_version()); IClientNetwork* piClient = NULL; bool bRet = p_circe_client_network_interface(__uuidof(IClientNetwork), (PVOID *)&piClient); assert(bRet && piClient); if (bRet && piClient) { test_client(piClient); } } ::FreeLibrary(hDll); } getchar(); return 0; }
static void test_client_maybe(void) { #ifndef WIN32 /* Must get Windows Curl transport working for this to work */ test_client(); #endif }
int main() { socket_init(); test_client(); socket_destory(); getchar(); return 0; }
void test_find_id_from_basename() { char const* basename = "/find_id_from_prefix_test/"; test_client t1 = test_client::create(hpx::find_here()); hpx::id_type client_id = t1.get_id(); HPX_TEST_NEQ(hpx::naming::invalid_id, client_id); // register our component with AGAS HPX_TEST((hpx::register_with_basename(basename, client_id).get())); // wait for all localities to register their component std::vector<hpx::id_type> localities = hpx::find_all_localities(); std::vector<std::size_t> sequence_nrs; std::vector<hpx::future<hpx::id_type> > ids; sequence_nrs.reserve(localities.size()); ids.reserve(localities.size()); for (hpx::id_type const& locality : localities) { std::size_t nr = hpx::naming::get_locality_id_from_id(locality); sequence_nrs.push_back(nr); ids.push_back(hpx::find_from_basename(basename, nr)); } HPX_TEST_EQ(ids.size(), sequence_nrs.size()); // retrieve all component ids std::set<hpx::id_type> component_localities; for (hpx::future<hpx::id_type>& f : ids) { hpx::id_type id = f.get(); hpx::id_type locality = test_client(id).call(); std::pair<std::set<hpx::id_type>::iterator, bool> p = component_localities.insert(locality); HPX_TEST(p.second); // every id should be unique } HPX_TEST_EQ(component_localities.size(), localities.size()); // make sure that components are on all localities for (hpx::id_type const& id : localities) { HPX_TEST(component_localities.find(id) != component_localities.end()); } }
int main(int argc, const char **argv) { if (argc < 2) usage(); if (!strcmp(argv[1], "client")) test_client(argc - 1, argv + 1); else if (!strcmp(argv[1], "server")) test_server(argc - 1, argv + 1); else if (!strcmp(argv[1], "principal")) test_get_principal_name(argc - 1, argv + 1); else usage(); return (0); }
int main( int argc, const char* argv[] ) { int test = argc > 1 ? atoi(argv[1]) : 0; if (argc >= 3) { verbosity = atoi(argv[2]); verbose = verbosity > 0 ? true : false; veryVerbose = verbosity > 1 ? true : false; veryVeryVerbose = verbosity > 2 ? true : false; std::cout << verbosity << std::endl; } set_up_signal_handler(); if (verbose) std::cout << "TEST " << __FILE__ << " CASE " << test << std::endl; switch (test) { case 0: case 1: { mrm::HTTPServer server; if (server.startServer() < 0) exit(1); // main loop while (server.acceptConnection() >= 0); } break; case 2: { if (verbose) std::cout << "TEST RESPONSE" << std::endl; test_response(); } break; case 3: { if (verbose) std::cout << "TEST REQUEST" << std::endl; test_request(); } break; case 4 : { if (verbose) std::cout << "TEST CLIENT" << std::endl; test_client(); } break; default: { std::cerr << "WARNING: CASE `" << test << "' NOT FOUND." << std::endl; testStatus = -1; } } return testStatus; }
// ask the server to create a new instance hpx::id_type test_server::create_new() const { return test_client().get_gid(); // this waits for the new object to be created }
test_client create_new() const { create_new_action new_; return test_client(hpx::async(new_, this->get_gid())); }
int main() { return -test_client(); }
/* * This routine drives the logging and interactive I/O loop. It polls for * input from the zone side of the fd (output to stdout/stderr), and from the * client (input to the zone's stdin). Additionally, it polls on the server * fd, and disconnects any clients that might try to hook up with the zone * while the fd's are in use. * * Data from the zone's stdout and stderr is formatted in json and written to * the log file whether an interactive client is connected or not. * * When the client first calls us up, it is expected to send a line giving its * "identity"; this consists of the string 'IDENT <pid> <locale>'. This is so * that we can report that the fd's are busy, along with some diagnostics * about who has them busy; the locale is ignore here but kept for compatability * with the zlogin code when running on the zone's console. * * We need to handle the case where there is no server within the zone (or * the server gets stuck) and data that we're writing to the zone server's * stdin fills the pipe. Because open_fd() always opens non-blocking our * writes could return -1 with EAGAIN. Since we ignore errors on the write * to stdin, we won't get blocked. */ static void do_zfd_io(int gzservfd, int gzerrfd, int stdinfd, int stdoutfd, int stderrfd) { struct pollfd pollfds[6]; char ibuf[BUFSIZ + 1]; int cc, ret; int clifd = -1; int clierrfd = -1; int pollerr = 0; char clilocale[MAXPATHLEN]; pid_t clipid = 0; uint_t flags = 0; /* client, watch for read events */ pollfds[0].fd = clifd; pollfds[0].events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI | POLLERR | POLLHUP | POLLNVAL; /* stdout, watch for read events */ pollfds[1].fd = stdoutfd; pollfds[1].events = pollfds[0].events; /* stderr, watch for read events */ pollfds[2].fd = stderrfd; pollfds[2].events = pollfds[0].events; /* the server stdin/out socket; watch for events (new connections) */ pollfds[3].fd = gzservfd; pollfds[3].events = pollfds[0].events; /* the server stderr socket; watch for events (new connections) */ pollfds[4].fd = gzerrfd; pollfds[4].events = pollfds[0].events; /* the eventstream; any input means the zone is halting */ pollfds[5].fd = eventstream[1]; pollfds[5].events = pollfds[0].events; while (!shutting_down) { pollfds[0].revents = pollfds[1].revents = 0; pollfds[2].revents = pollfds[3].revents = 0; pollfds[4].revents = pollfds[5].revents = 0; ret = poll(pollfds, 6, -1); if (ret == -1 && errno != EINTR) { zerror(zlogp, B_TRUE, "poll failed"); /* we are hosed, close connection */ break; } /* event from client side */ if (pollfds[0].revents) { if (pollfds[0].revents & POLLHUP && flags & ZLOGIN_ZFD_EOF) { /* Let the client know */ (void) ioctl(stdinfd, ZFD_EOF); } if (pollfds[0].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { errno = 0; cc = read(clifd, ibuf, BUFSIZ); if (cc <= 0 && (errno != EINTR) && (errno != EAGAIN)) { break; } /* * See comment for this function on what * happens if there is no reader in the zone. */ (void) write(stdinfd, ibuf, cc); } else { pollerr = pollfds[0].revents; zerror(zlogp, B_FALSE, "closing connection " "with client, pollerr %d\n", pollerr); break; } } /* event from the zone's stdout */ if (pollfds[1].revents) { if (pollfds[1].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { errno = 0; cc = read(stdoutfd, ibuf, BUFSIZ); if (cc <= 0 && (errno != EINTR) && (errno != EAGAIN)) break; if (cc > 0) { wr_log_msg(ibuf, cc, 1); /* * Lose output if no one is listening, * otherwise pass it on. */ if (clifd != -1) (void) write(clifd, ibuf, cc); } } else { pollerr = pollfds[1].revents; zerror(zlogp, B_FALSE, "closing connection with stdout zfd, " "pollerr %d\n", pollerr); break; } } /* event from the zone's stderr */ if (pollfds[2].revents) { if (pollfds[2].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { errno = 0; cc = read(stderrfd, ibuf, BUFSIZ); if (cc <= 0 && (errno != EINTR) && (errno != EAGAIN)) break; if (cc > 0) { wr_log_msg(ibuf, cc, 2); /* * Lose output if no one is listening, * otherwise pass it on. */ if (clierrfd != -1) (void) write(clierrfd, ibuf, cc); } } else { pollerr = pollfds[2].revents; zerror(zlogp, B_FALSE, "closing connection with stderr zfd, " "pollerr %d\n", pollerr); break; } } /* event from primary server stdin/out socket */ if (pollfds[3].revents && (pollfds[3].revents & (POLLIN | POLLRDNORM))) { if (clifd != -1) { /* * Test the client to see if it is really * still alive. If it has died but we * haven't yet detected that, we might * deny a legitimate connect attempt. If it * is dead, we break out; once we tear down * the old connection, the new connection * will happen. */ if (test_client(clifd) == -1) { break; } /* we're already handling a client */ reject_client(gzservfd, clipid); } else if ((clifd = accept_client(gzservfd, &clipid, clilocale, sizeof (clilocale), &flags)) != -1) { pollfds[0].fd = clifd; } else { break; } } /* connection event from server stderr socket */ if (pollfds[4].revents && (pollfds[4].revents & (POLLIN | POLLRDNORM))) { if (clifd == -1) { /* * This shouldn't happen since the client is * expected to connect on the primary socket * first. If we see this, tear everything down * and start over. */ zerror(zlogp, B_FALSE, "GZ zfd stderr " "connection attempt with no GZ primary\n"); break; } assert(clierrfd == -1); if ((clierrfd = accept_client(gzerrfd, NULL, NULL, 0, NULL)) != -1) { /* * Once connected, we no longer poll on the * gzerrfd since the CLI handshake takes place * on the primary gzservfd. */ pollfds[4].fd = -1; } else { break; } } /* * Watch for events on the eventstream. This is how we get * notified of the zone halting, etc. It provides us a * "wakeup" from poll when important things happen, which * is good. */ if (pollfds[5].revents) { break; } } if (clifd != -1) { (void) shutdown(clifd, SHUT_RDWR); (void) close(clifd); } if (clierrfd != -1) { (void) shutdown(clierrfd, SHUT_RDWR); (void) close(clierrfd); } }
test_client create_new(hpx::id_type const& id) const { create_new_action new_; return test_client(hpx::async(new_, this->get_gid(), id)); }
int main() { if (test_client()) return 1; }
/* * This routine drives the console I/O loop. It polls for input from the * master side of the console (output to the console), and from the client * (input from the console user). Additionally, it polls on the server fd, * and disconnects any clients that might try to hook up with the zone while * the console is in use. * * When the client first calls us up, it is expected to send a line giving * its "identity"; this consists of the string 'IDENT <pid> <locale>'. * This is so that we can report that the console is busy along with * some diagnostics about who has it busy; the locale is used so that * asynchronous messages about zone state (like the NOTICE: zone halted * messages) can be output in the user's locale. */ static void do_console_io(zlog_t *zlogp, int consfd, int servfd) { struct pollfd pollfds[4]; char ibuf[BUFSIZ]; int cc, ret; int clifd = -1; int pollerr = 0; char clilocale[MAXPATHLEN]; pid_t clipid = 0; /* console side, watch for read events */ pollfds[0].fd = consfd; pollfds[0].events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI | POLLERR | POLLHUP | POLLNVAL; /* client side, watch for read events */ pollfds[1].fd = clifd; pollfds[1].events = pollfds[0].events; /* the server socket; watch for events (new connections) */ pollfds[2].fd = servfd; pollfds[2].events = pollfds[0].events; /* the eventstram; watch for events (e.g.: zone halted) */ pollfds[3].fd = eventstream[1]; pollfds[3].events = pollfds[0].events; for (;;) { pollfds[0].revents = pollfds[1].revents = 0; pollfds[2].revents = pollfds[3].revents = 0; ret = poll(pollfds, sizeof (pollfds) / sizeof (struct pollfd), -1); if (ret == -1 && errno != EINTR) { zerror(zlogp, B_TRUE, "poll failed"); /* we are hosed, close connection */ break; } /* event from console side */ if (pollfds[0].revents) { if (pollfds[0].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { errno = 0; cc = read(consfd, ibuf, BUFSIZ); if (cc <= 0 && (errno != EINTR) && (errno != EAGAIN)) break; /* * Lose I/O if no one is listening */ if (clifd != -1 && cc > 0) (void) write(clifd, ibuf, cc); } else { pollerr = pollfds[0].revents; zerror(zlogp, B_FALSE, "closing connection with (console) " "pollerr %d\n", pollerr); break; } } /* event from client side */ if (pollfds[1].revents) { if (pollfds[1].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { errno = 0; cc = read(clifd, ibuf, BUFSIZ); if (cc <= 0 && (errno != EINTR) && (errno != EAGAIN)) break; (void) write(consfd, ibuf, cc); } else { pollerr = pollfds[1].revents; zerror(zlogp, B_FALSE, "closing connection with (client) " "pollerr %d\n", pollerr); break; } } /* event from server socket */ if (pollfds[2].revents && (pollfds[2].revents & (POLLIN | POLLRDNORM))) { if (clifd != -1) { /* * Test the client to see if it is really * still alive. If it has died but we * haven't yet detected that, we might * deny a legitimate connect attempt. If it * is dead, we break out; once we tear down * the old connection, the new connection * will happen. */ if (test_client(clifd) == -1) { break; } /* we're already handling a client */ reject_client(servfd, clipid); } else if ((clifd = accept_client(servfd, &clipid, clilocale, sizeof (clilocale))) != -1) { pollfds[1].fd = clifd; } else { break; } } /* * Watch for events on the eventstream. This is how we get * notified of the zone halting, etc. It provides us a * "wakeup" from poll when important things happen, which * is good. */ if (pollfds[3].revents) { int evt = eventstream_read(); /* * After we drain out the event, if we aren't servicing * a console client, we hop back out to our caller, * which will check to see if it is time to shutdown * the daemon, or if we should take another console * service lap. */ if (clifd == -1) { break; } event_message(clifd, clilocale, evt); /* * Special handling for the message that the zone is * uninstalling; we boot the client, then break out * of this function. When we return to the * serve_console loop, we will see that the zone is * in a state < READY, and so zoneadmd will shutdown. */ if (evt == Z_EVT_ZONE_UNINSTALLING) { break; } } } if (clifd != -1) { (void) shutdown(clifd, SHUT_RDWR); (void) close(clifd); } }