diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-10-15 15:38:56 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-10-15 15:38:56 +0000 |
commit | c436cba26b58a4aae09cb8b3b8ade9fb9903e805 (patch) | |
tree | 395ea5872f23dc1c353bdeca76fc7f0809cecfac | |
parent | cbd2561e1c17f8f82a2b985c4056120e6aa2c6d5 (diff) | |
download | ATCD-c436cba26b58a4aae09cb8b3b8ade9fb9903e805.tar.gz |
ChangeLogTag:Tue Oct 15 06:56:18 2002 Patrick J. McNerthney <ace@mcnerthney.com>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 5 | ||||
-rw-r--r-- | tests/SPIPE_Test.cpp | 83 |
3 files changed, 90 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index 8bdc8beb7f9..69aba5fc88f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 15 06:56:18 2002 Patrick J. McNerthney <ace@mcnerthney.com> + + * tests/SPIPE_Test.cpp: Added support for testing the new Windows + bytestream mode. + Mon Oct 14 20:47:21 2002 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> * ace/SPIPE_Acceptor.cpp (open): Changed "mode" to "pipe_mode", diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 8bdc8beb7f9..69aba5fc88f 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,8 @@ +Tue Oct 15 06:56:18 2002 Patrick J. McNerthney <ace@mcnerthney.com> + + * tests/SPIPE_Test.cpp: Added support for testing the new Windows + bytestream mode. + Mon Oct 14 20:47:21 2002 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> * ace/SPIPE_Acceptor.cpp (open): Changed "mode" to "pipe_mode", diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp index ec493532f1a..16671e85fd7 100644 --- a/tests/SPIPE_Test.cpp +++ b/tests/SPIPE_Test.cpp @@ -29,7 +29,7 @@ #include "ace/SPIPE_Connector.h" #include "ace/SPIPE_Acceptor.h" -ACE_RCSID(tests, SPIPE_Test, "$Id$") +ACE_RCSID(tests, SPIPE_Test, "SPIPE_Test.cpp,v 4.36 2002/03/06 21:48:03 nanbor Exp") #if defined (ACE_HAS_STREAM_PIPES) \ || (defined (ACE_WIN32) && defined(ACE_HAS_WINNT4) \ @@ -51,18 +51,49 @@ client (void *) ACE_SPIPE_Stream cli_stream; ACE_SPIPE_Connector con; - ACE_OS::sleep (10); + ACE_OS::sleep (5); if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), rendezvous, 1)); for (const char *c = ACE_ALPHABET; *c != '\0'; c++) if (cli_stream.send (c, 1) == -1) - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n"))); + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send"))); if (cli_stream.close () == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("close"))); +#if (defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) + + // Wait for server to get ready... + ACE_OS::sleep (1); + + // Connect in bytestream-oriented mode. + if (con.connect (cli_stream, + ACE_SPIPE_Addr (rendezvous), + 0, + ACE_Addr::sap_any, + 0, + O_RDWR, + 0, + 0, + PIPE_READMODE_BYTE) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), rendezvous, 1)); + + // Write out the alphabet all at once. + if (cli_stream.send_n (ACE_ALPHABET, + ACE_OS::strlen (ACE_ALPHABET)) != ACE_OS::strlen (ACE_ALPHABET)) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n"))); + + // Write out the alphabet one byte at a time + for (c = ACE_ALPHABET; *c != '\0'; c++) + if (cli_stream.send (c, 1) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send"))); + + if (cli_stream.close () == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("close"))); +#endif + #if !defined (ACE_WIN32) ACE_OS::exit (0); #endif @@ -100,6 +131,52 @@ server (void *) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("End of connection. Closing handle\n"))); new_stream.close (); acceptor.close (); + +#if (defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) + // Initialize an NT bytestream named pipe listener. + if (acceptor.open (ACE_SPIPE_Addr (rendezvous), + 1, + 0, + 0, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), ACE_TEXT ("open"), 1)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting for connection\n"))); + + // Accept a client connection + if (acceptor.accept (new_stream, 0) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), ACE_TEXT ("accept"), 1)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Accepted connection\n"))); + + // The client will write the entire buffer at once, verify that we + // can stream it in one byte at a time. + for (t = ACE_ALPHABET; *t; t++;) + { + if (new_stream.recv (buf, 1) <= 0) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), ACE_TEXT ("recv"), 1)); + break; + } + ACE_ASSERT (*t == buf[0]); + } + + // Wait for the client to stream in the buffer one byte at a time. + + ACE_OS::sleep (1); + + // Verify that we can read the stream of individual bytes all at + // once. + if (new_stream.recv (buf, sizeof(buf)) != ACE_OS::strlen (ACE_ALPHABET)) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n%a"), ACE_TEXT ("recv"), 1)); + else + ACE_ASSERT(memcmp(ACE_ALPHABET, buf, ACE_OS::strlen (ACE_ALPHABET)) == 0); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("End of connection. Closing handle\n"))); + new_stream.close (); + acceptor.close (); +#endif /* (defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) */ + return 0; } #endif /* TEST_HAS_STREAM_PIPES */ |