TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::UInt16 portNumber, TCPServerParams::Ptr pParams): _socket(ServerSocket(portNumber)), _pDispatcher(new TCPServerDispatcher(pFactory, Poco::ThreadPool::defaultPool(), pParams)), _thread(threadName(_socket)), _stopped(true) { }
int MomentHTTPServer::main(const std::vector<std::string> &) { if(http_port == -1 || admin_http_port == -1) return Application::EXIT_NOHOST; // this error is most suitable HTTPServer * http_server = new HTTPServer(new HttpHandlerFactory, ServerSocket(http_port), new HTTPServerParams); HTTPServer * admin_http_server = new HTTPServer(new AdminHttpHandlerFactory, ServerSocket(admin_http_port), new HTTPServerParams); http_server->start(); admin_http_server->start(); waitForTerminationRequest(); // wait for CTRL-C or kill http_server->stop(); admin_http_server->stop(); return Application::EXIT_OK; }
int main(int argc, const char * argv[]) { ServerSocket mainSocket = ServerSocket(4444); Socket socket = mainSocket.acceptConnection(); socket.beginHandling(); socket.closeSocket(); mainSocket.close(); return 0; }
tERROR CProxySessionManager::ProxyManagerThread() { SOCKET server, server_v6, CrService, CrService_v6; cERROR err = errOK; KLSTD_TRACE1 (KLMC_TRACELEVEL, "CProxySessionManager::ProxyManagerThread => begin on port %d...", m_ListenPort ); server = ServerSocket( m_ListenPort, PF_INET ); server_v6 = ServerSocket( m_ListenPort, PF_INET6 ); CrService = ServerSocket( m_ServPort, PF_INET ); CrService_v6 = ServerSocket( m_ServPort, PF_INET6 ); KLSTD_TRACE4 (KLMC_TRACELEVEL, "CProxySessionManager::ProxyManagerThread => Server(0x%x) Server6(0x%x) Service(0x%x) Service6(0x%x)", server, server_v6, CrService, CrService_v6); ProxyMain( server, server_v6, CrService, CrService_v6 ); FinishActiveSessions(); // ¬ообще лочить имхо необ¤зательно, т.к. к данному моменту все клиенты // избавились от своих потоков, т.е. не может быть одновременного доступа к списку // m_WaitSessionList. // т.е. просто "на вс¤кий случай" ... EnterCriticalSection( &m_WaitSessionListLock ); m_WaitSessionList.clear(); LeaveCriticalSection( &m_WaitSessionListLock ); /* CLOSESOCKET( server ); CLOSESOCKET( server_v6 ); CLOSESOCKET( CrService ); CLOSESOCKET( CrService_v6 ); */ KLSTD_TRACE0 (KLMC_TRACELEVEL, "CProxySessionManager::ProxyManagerThread => finish..."); return err; }
void NetworkingModule::init() { if(this->_hasInited) { return; } this->dispatch->registerPacket(new UpdateExecutor(this->_core, this)); this->dispatch->registerPacket(new PeerExecutor(this->sockets)); this->dispatch->registerPacket(new PeerConnector(this->sockets)); this->dispatch->registerPacket(new HostPortSetter()); this->dispatch->registerPacket(new SyncRequest(this->_core)); this->dispatch->registerPacket(new WhoIs(this->_core)); this->dispatch->registerPacket(new WhoIsExecutor(this->_core)); //first setup our server socket this->serverSocket = new ServerSocket(ServerSocket(IPV4, TCP, false)); this->serverSocket->doBind(0); this->serverSocket->doListen(); std::cout << "Listening for conncetions on port: " << this->serverSocket->boundPort() << "\n"; this->_hasInited = true; }
int main(int argc, char **argv) { _addr a; try { /* get command-line arguments */ if (argc != 2 ) { printf( "Usage: %s [domainname]\n", argv[0] ); return 1; } else { dyndomain = argv[1]; txt_to_addr(&a, "any"); } poslib_config_init(); /* bring up posadis */ servers.push_front(ServerSocket(ss_udp, udpcreateserver(&a))); // use the posadis logging system pos_log(context_none, log_info, "Proof of concept DNS server starting up..."); // set signal handlers signal(SIGINT, cleanup); signal(SIGTERM, cleanup); // set query function handle_query = my_handle_query; // run server posserver_run(); } catch (PException p) { printf("Fatal exception: %s\n", p.message); return 1; } return 0; }
int main (int args, char* []){ ASocket ServerSocket(3000,5); ServerSocket.listenSocket(); return 0; }