int main(void) { hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL); clients = (int*)malloc(sizeof(int)*MAX_CLIENTS); ss = socket_server_create(socket_callback); HANDLE h = (HANDLE)_beginthreadex(NULL, 0, test, 0, 0, NULL); WaitForSingleObject(h, INFINITE); int i; for (i=0; i<MAX_CLIENTS; ++i) { socket_server_close(ss, 100+i, clients[i]); } socket_server_exit(ss); socket_server_wait_for_exit(ss); socket_server_release(ss); printf("test end\n"); printf("expected bytes: %d send bytes: %d recv bytes: %d\n", EXPECTED_BYTES, sent_bytes, recv_bytes); free(clients); system("pause"); return 0; }
/* main program */ int main(int argc, const char *argv[]) { struct poptOption popt_options[] = { POPT_AUTOHELP { "socket", 0, POPT_ARG_STRING, &globals.socketname, 0, "local socket name", "filename" }, POPT_TABLEEND }; int opt; const char **extra_argv; int extra_argc = 0; poptContext pc; DEBUGLEVEL = DEBUG_INFO; pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { default: fprintf(stderr, "Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); exit(1); } } /* setup the remaining options for the main program to use */ extra_argv = poptGetArgs(pc); if (extra_argv) { extra_argv++; while (extra_argv[extra_argc]) extra_argc++; } if (globals.socketname == NULL) { DEBUG(DEBUG_CRIT,("Socket name is undefined\n")); exit(1); } if (socket_server_create()) { DEBUG(DEBUG_CRIT,("Socket error: exiting\n")); exit(1); } if (fork_helper()) { DEBUG(DEBUG_CRIT,("Forking error: exiting\n")); exit(1); } /* FIXME: Test tcp_checksum6, tcp_checksum */ /* FIXME: Test ctdb_sys_send_arp, ctdb_sys_send_tcp */ /* FIXME: Test ctdb_sys_{open,close}_capture_socket, ctdb_sys_read_tcp_packet */ test_ctdb_sys_check_iface_exists(); test_ctdb_get_peer_pid(); socket_server_close(); DEBUG(DEBUG_INFO,("%d/%d tests successfull\n", globals.successcount, globals.testcount)); return 0; }
int main(void) { clients = (int*)malloc(sizeof(int)*MAX_CLIENTS); ss = socket_server_create(socket_callback); HANDLE h = (HANDLE)_beginthreadex(NULL, 0, test, 0, 0, NULL); WaitForSingleObject(h, INFINITE); int i; for (i=0; i<MAX_CLIENTS; ++i) { socket_server_close(ss, 100+i, clients[i]); } socket_server_exit(ss); socket_server_wait_for_exit(ss); socket_server_release(ss); printf("test end\n"); free(clients); system("pause"); return 0; }
void skynet_socket_close(struct skynet_context *ctx, int id) { uint32_t source = skynet_context_handle(ctx); socket_server_close(SOCKET_SERVER, source, id); }