/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// This example is from the ACE Programmers Guide.
////  Chapter:  "The Acceptor/Connector"  (Connection Initialization)
//// For details please see the guide at
//// http://www.cs.wustl.edu/~schmidt/ACE.html
////  AUTHOR: Umar Syyid ([email protected])
//// and Ambreen Ilyas ([email protected])
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Example3

class My_Svc_Handler:
public ACE_Svc_Handler <ACE_LSOCK_STREAM,ACE_NULL_SYNCH>{
public:
int open(void*){
 ACE_DEBUG((LM_DEBUG,"Connection established"));
 ACE_Reactor::instance() ->register_handler(this,ACE_Event_Handler::READ_MASK);
   }

 int handle_input(ACE_HANDLE){
  char* data= new char[DATA_SIZE];
  peer().recv_n(data,DATA_SIZE);
  ACE_OS::printf("<< %s\n",data);
  return 0;
  }
};

typedef ACE_Acceptor<My_Svc_Handler,ACE_LSOCK_ACCEPTOR> MyAcceptor;

int main(int argc, char* argv[]){
 ACE_UNIX_Addr addr("/tmp/addr.ace");
 MyAcceptor acceptor(address, ACE_Reactor::instance());

while(1) /* Start the reactors event loop */
  ACE_Reactor::instance()->handle_events();
}

 Next Example