diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-04 21:21:17 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-04 21:21:17 +0000 |
commit | 5ac928e015cfc4f7782f14c58d4ac5524bf8b6ad (patch) | |
tree | af86b2345c376a2a17ed4a31577601c3f5cdf9a8 /examples | |
parent | e7e5eed828e3c3bc812a971bda436e03be7934aa (diff) | |
download | ATCD-5ac928e015cfc4f7782f14c58d4ac5524bf8b6ad.tar.gz |
use non-blocking connect on VxWorks
Diffstat (limited to 'examples')
-rw-r--r-- | examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp | 21 | ||||
-rw-r--r-- | examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp | 4 |
2 files changed, 21 insertions, 4 deletions
diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp index 9801bde8199..3cec94a92e5 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp @@ -16,32 +16,45 @@ int main (int argc, char *argv[]) char buf[BUFSIZ]; ACE_SOCK_Stream cli_stream; - ACE_INET_Addr remote_addr (r_port, host); - ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); // Initiate timed, non-blocking connection with server. ACE_SOCK_Connector con; // Attempt a non-blocking connect to the server, reusing the local // addr if necessary. +#if defined (VXWORKS) + ACE_DEBUG ((LM_DEBUG, "starting connect\n")); + + fprintf (stderr, + "CPP-inclient.cpp: you'll need to hard code the hostname:port on VxWorks!!!!\n"); + ACE_INET_Addr remote_addr ("<hard-coded hostname:10002"); + if (con.connect (cli_stream, remote_addr) == -1) +#else + ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); + + ACE_INET_Addr remote_addr (r_port, host); if (con.connect (cli_stream, remote_addr, (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) +#endif /* VXWORKS */ { if (errno != EWOULDBLOCK) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); ACE_DEBUG ((LM_DEBUG, "starting timed connect\n")); +#if !defined (VXWORKS) // Check if non-blocking connection is in progress, // and wait up to timeout seconds for it to complete. - if (con.complete (cli_stream, &remote_addr, &timeout) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "complete failed"), 1); else ACE_DEBUG ((LM_DEBUG, "connected to %s\n", remote_addr.get_host_name ())); +#endif /* !VXWORKS */ } +#if !defined (VXWORKS) if (cli_stream.disable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "disable"), 1); +#endif /* !VXWORKS */ // Send data to server (correctly handles "incomplete writes"). diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp index 96013f6f19f..313d1c683b6 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp @@ -29,9 +29,11 @@ main (int argc, char *argv[]) // Create a server, reuse the address. if (peer_acceptor.open (server_addr, 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); +#if !defined(VXWORKS) // Set the peer acceptor into non-blocking mode. else if (peer_acceptor.enable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), 1); +#endif /* !VXWORKS */ else if (peer_acceptor.get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), 1); @@ -70,9 +72,11 @@ main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "client %s connected from %d\n", cli_addr.get_host_name (), cli_addr.get_port_number ())); +#if !defined(VXWORKS) // Enable non-blocking I/O. if (new_stream.enable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "enable"), -1); +#endif /* !VXWORKS */ handle_set.reset (); handle_set.set_bit (new_stream.get_handle ()); |