static void blocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) { Svc_Handler *svc_handler; ACE_NEW (svc_handler, Svc_Handler); // Perform a blocking connect to the server. if (con.connect (svc_handler, server_addr) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("connection failed"))); else { // Send the data to the server. svc_handler->send_data (); // Close the connection completely. if (svc_handler->close (1) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("close"))); } }
static void timed_blocking_connect (CONNECTOR &con, const ACE_INET_Addr &server_addr) { ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); ACE_Synch_Options options (ACE_Synch_Options::USE_TIMEOUT, tv); Svc_Handler *svc_handler; ACE_NEW (svc_handler, Svc_Handler); // Perform a timed-blocking connect to the server (this should // connect quickly since we're in the same address space or same // host). if (con.connect (svc_handler, server_addr, options) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("connection failed"))); else { // Send the data to the server. svc_handler->send_data (); // Close the connection completely. if (svc_handler->close (1) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("close"))); } }