diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-06-18 18:53:27 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-06-18 18:53:27 +0000 |
commit | 152c0f5c127eac99b5c9097aa4db2b34e14e6dd0 (patch) | |
tree | 0d399a92623e98588cd34e4fe0c2cf7fed880173 /examples/APG/Sockets/Basic_Robust.cpp | |
parent | 7e7f4a5d3e77a42e648b7dd2e1b9cf23a3780955 (diff) | |
download | ATCD-MyACE.tar.gz |
This commit was manufactured by cvs2svn to create branch 'MyACE'.MyACE
Diffstat (limited to 'examples/APG/Sockets/Basic_Robust.cpp')
-rw-r--r-- | examples/APG/Sockets/Basic_Robust.cpp | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/examples/APG/Sockets/Basic_Robust.cpp b/examples/APG/Sockets/Basic_Robust.cpp deleted file mode 100644 index 361519a4486..00000000000 --- a/examples/APG/Sockets/Basic_Robust.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// $Id$ - -#include "ace/OS_NS_errno.h" -#include "ace/INET_Addr.h" -#include "ace/SOCK_Stream.h" -#include "ace/SOCK_Connector.h" -#include "ace/Log_Msg.h" -#include "ace/Time_Value.h" - -int ACE_TMAIN (int, ACE_TCHAR *[]) -{ - /* - * Here we will use the default ctor and the set() - * method to configure it. After each set() we will - * display the address as a string and then connect - * to each respective server. We can reuse the addr - * instance once connection has been established. - * - // Listing 1 code/ch06 - ACE_INET_Addr addr; - ... - addr.set ("HAStatus", ACE_LOCALHOST); - ... - addr.set ("HALog", ACE_LOCALHOST); - // Listing 1 - * - */ - - ACE_INET_Addr addr; - ACE_TCHAR peerAddress[64]; - - // Listing 2 code/ch06 - addr.set (ACE_TEXT("HAStatus"), ACE_LOCALHOST); - if (addr.addr_to_string (peerAddress, - sizeof(peerAddress), 0) == 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Connecting to %s\n"), - peerAddress)); - } - // Listing 2 - - // Listing 3 code/ch06 - ACE_SOCK_Stream status; - ACE_OS::last_error(0); - ACE_SOCK_Connector statusConnector (status, addr); - if (ACE_OS::last_error()) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("status")), 100); - // Listing 3 - - addr.set (ACE_TEXT("HALog"), ACE_LOCALHOST); - if (addr.addr_to_string (peerAddress, - sizeof(peerAddress), 0) == 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Connecting to %s\n"), - peerAddress )); - } - - // Listing 4 code/ch06 - ACE_SOCK_Connector logConnector; - ACE_Time_Value timeout (10); - ACE_SOCK_Stream log; - if (logConnector.connect (log, addr, &timeout) == -1) - { - if (ACE_OS::last_error() == ETIME) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Timeout while ") - ACE_TEXT ("connecting to log server\n"))); - } - else - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("log"))); - } - return (101); - } - // Listing 4 - - /* - * We generally let the OS pick our local port number but - * if you want, you can choose that also: - // Listing 5 code/ch06 - ACE_SOCK_Connector logConnector; - ACE_INET_Addr local (4200, ACE_LOCALHOST); - if (logConnector.connect (log, addr, 0, local) == -1) - { - ... - // Listing 5 - } - */ - - char buf[64]; - - // Listing 6 code/ch06 - ACE_Time_Value sendTimeout (0, 5); - if (status.send_n ("uptime\n", 7, &sendTimeout) == -1) - { - if (ACE_OS::last_error() == ETIME) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Timeout while sending ") - ACE_TEXT ("query to status server\n"))); - } - // Listing 6 - else - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("send_n"))); - } - return (102); - } - - // Listing 7 code/ch06 - ssize_t bc ; - ACE_Time_Value recvTimeout (0, 1); - if ((bc = status.recv (buf, sizeof(buf), &recvTimeout)) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("recv"))); - return (103); - } - - log.send_n (buf, bc); - // Listing 7 - - status.close (); - log.close (); - - return (0); -} |