[Ace-users] how to implement nonblocking reconnect using connector-acceptor pattern ?

hongxing777 at gmail.com hongxing777 at gmail.com
Thu Oct 18 15:35:52 CDT 2007

ACE version 5.6.1
Host windows xp sp2
Compiler ms visual studio 2003

In my app, I use ACE_Connector and an existing ACE_Svc_Handler object
to connect to the server. First, I call ACE_Connector::connect() with
USE_REACTOR options. If the server is not open or a connection is
dropped, handle_close is called.

Can I write reconnect logic in handle_close like the following:
int CMyHandler::handle_close(ACE_HANDLE handle, ACE_Reactor_Mask mask)
  ACE_Time_Value to(5);
  ACE_Synch_Options options(ACE_Synch_Options::USE_REACTOR, to);

  if(Connect_(this, server_addr_, options) == -1 &&
ACE_OS::last_error() != EWOULDBLOCK)
    return -1;

  return 0;

My question is:
What's the normal implement logic of  nonblocking reconnection ?
Is there any nonblocking reconnection example? In Chap 7 of C++NPv2,
there is only plain texts about that, but not in detail.


More information about the Ace-users mailing list