下面的程序会在7905端口持续监听,其他的什么也不做
#include <iostream> using namespace std; #include "ace/INET_Addr.h" #include "ace/Svc_Handler.h" #include "ace/SOCK_Stream.h" #include "ace/SOCK_Acceptor.h" #include "ace/Acceptor.h" class ClientService : public ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH> { }; int main(int, char *[]) { ACE_INET_Addr addr("7905"); typedef ACE_Acceptor<ClientService,ACE_SOCK_ACCEPTOR> ClientAcceptor; ClientAcceptor acceptor; if (acceptor.open(addr)== -1) { cout<<"acceptor open failed !"<<endl; return -1; } ACE_Reactor::instance()->run_reactor_event_loop(); return 0; };
ACE Acceptor Connector模式,布布扣,bubuko.com
原文:http://blog.csdn.net/calmreason/article/details/38367209