summaryrefslogtreecommitdiff
path: root/ACE/tests/HTBP/Send_Large_Msg
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/tests/HTBP/Send_Large_Msg')
-rw-r--r--ACE/tests/HTBP/Send_Large_Msg/.cvsignore4
-rw-r--r--ACE/tests/HTBP/Send_Large_Msg/Makefile.am64
-rw-r--r--ACE/tests/HTBP/Send_Large_Msg/Send_Large_Msg.mpc23
-rw-r--r--ACE/tests/HTBP/Send_Large_Msg/client.cpp98
-rwxr-xr-xACE/tests/HTBP/Send_Large_Msg/run_test.pl43
-rw-r--r--ACE/tests/HTBP/Send_Large_Msg/server.cpp103
6 files changed, 335 insertions, 0 deletions
diff --git a/ACE/tests/HTBP/Send_Large_Msg/.cvsignore b/ACE/tests/HTBP/Send_Large_Msg/.cvsignore
new file mode 100644
index 00000000000..955ffdc75d5
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/.cvsignore
@@ -0,0 +1,4 @@
+client
+client
+server
+server
diff --git a/ACE/tests/HTBP/Send_Large_Msg/Makefile.am b/ACE/tests/HTBP/Send_Large_Msg/Makefile.am
new file mode 100644
index 00000000000..2773356439b
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/Makefile.am
@@ -0,0 +1,64 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+noinst_PROGRAMS =
+
+## Makefile.Send_Large_Msg_Client.am
+
+if !BUILD_ACE_FOR_TAO
+
+noinst_PROGRAMS += client
+
+client_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/protocols
+
+client_SOURCES = \
+ client.cpp
+
+client_LDADD = \
+ $(top_builddir)/tests/libTest_Output.la \
+ $(ACE_BUILDDIR)/protocols/ace/HTBP/libACE_HTBP.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+
+## Makefile.Send_Large_Msg_Server.am
+
+if !BUILD_ACE_FOR_TAO
+
+noinst_PROGRAMS += server
+
+server_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/protocols
+
+server_SOURCES = \
+ server.cpp
+
+server_LDADD = \
+ $(top_builddir)/tests/libTest_Output.la \
+ $(ACE_BUILDDIR)/protocols/ace/HTBP/libACE_HTBP.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/tests/HTBP/Send_Large_Msg/Send_Large_Msg.mpc b/ACE/tests/HTBP/Send_Large_Msg/Send_Large_Msg.mpc
new file mode 100644
index 00000000000..d973b59748f
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/Send_Large_Msg.mpc
@@ -0,0 +1,23 @@
+// -*- MPC -*-
+//
+// $Id$
+
+project(*Server): aceexe, htbp {
+ exename = server
+ after += Test_Output
+ libs += Test_Output
+
+ Source_Files {
+ server.cpp
+ }
+}
+
+project(*Client): aceexe, htbp {
+ exename = client
+ after += Test_Output
+ libs += Test_Output
+
+ Source_Files {
+ client.cpp
+ }
+}
diff --git a/ACE/tests/HTBP/Send_Large_Msg/client.cpp b/ACE/tests/HTBP/Send_Large_Msg/client.cpp
new file mode 100644
index 00000000000..62cd9140da8
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/client.cpp
@@ -0,0 +1,98 @@
+// $Id$
+
+#include "tests/test_config.h"
+
+#include "ace/HTBP/HTBP_Session.h"
+#include "ace/HTBP/HTBP_Stream.h"
+#include "ace/HTBP/HTBP_Addr.h"
+#include "ace/HTBP/HTBP_ID_Requestor.h"
+#include "ace/HTBP/HTBP_Environment.h"
+
+#include "ace/Log_Msg.h"
+
+const ssize_t Send_Size = 4*1024;
+const size_t Loops = 10;
+const size_t Total_Size = Send_Size * Loops;
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACE_START_TEST (ACE_TEXT ("HTBP_Send_Large_Msg_client"));
+
+ ACE_OS::socket_init (ACE_WSOCK_VERSION);
+
+ if (argc < 2)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: client <remote host>\n"),
+ 0);
+ ACE::HTBP::Environment env;
+#if 0 // this should be a taken from a command line argument
+ env.import_config (ACE_TEXT("../HTBP_Config.conf"));
+#endif /* 0 */
+
+
+ ACE::HTBP::ID_Requestor req (&env);
+ ACE::HTBP::Addr local(ACE_TEXT_ALWAYS_CHAR(req.get_HTID()));
+
+ unsigned remote_port = 8088;
+ const ACE_TCHAR * remote_host = argv[1];
+
+ unsigned proxy_port = 0;
+ ACE_TString proxy_host;
+
+ if (env.get_proxy_port(proxy_port) != 0 ||
+ env.get_proxy_host(proxy_host) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("no proxy address in ")
+ ACE_TEXT("config, using direct connect\n")));
+ proxy_port = remote_port;
+ proxy_host = remote_host;
+ }
+
+ ACE_INET_Addr proxy(proxy_port,proxy_host.c_str());
+ ACE::HTBP::Addr remote (remote_port,ACE_TEXT_ALWAYS_CHAR(remote_host));
+
+ ACE::HTBP::Session session(remote,
+ local,
+ ACE::HTBP::Session::next_session_id(),
+ &proxy);
+
+ ACE::HTBP::Stream *stream = new ACE::HTBP::Stream(&session);
+ ACE_DEBUG ((LM_DEBUG,ACE_TEXT("Sending message\n")));
+ char buffer[Send_Size];
+ ACE_OS::memset (buffer,'a',Send_Size);
+ ssize_t n = 0;
+ for (size_t i = 0; i < Loops ; ++i)
+ {
+ errno = 0;
+ while (n < Send_Size)
+ {
+ n += stream->send (buffer+n,Send_Size);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Sending %d of %d\n"), n, Send_Size));
+ }
+ if (n == -1 && errno != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("%p\n %d"),
+ ACE_TEXT("stream send"), errno), -1);
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("In round %d, send returned %d\n"), i, n));
+ }
+
+ buffer[0] = 0;
+ n = stream->recv (buffer,1000);
+ while (n == -1)
+ {
+ if (errno == EWOULDBLOCK)
+ n = stream->recv (buffer,1000);
+ else
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("%p\n"),
+ ACE_TEXT("stream.recv")),-1);
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT("received %d, %s\n"),n,buffer));
+
+ ACE_END_TEST;
+ return 0;
+}
diff --git a/ACE/tests/HTBP/Send_Large_Msg/run_test.pl b/ACE/tests/HTBP/Send_Large_Msg/run_test.pl
new file mode 100755
index 00000000000..6b295afbf17
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/run_test.pl
@@ -0,0 +1,43 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::Run_Test;
+use Sys::Hostname;
+
+$iorfile = PerlACE::LocalFile ("server.ior");
+
+unlink $iorfile;
+$status = 0;
+
+$SV = new PerlACE::Process ("server");
+$host = hostname();
+
+# The client code should later be modified to get the hostname
+# using ACE_OS::hostname so the same script can be run on all
+# hosts without havng to reset the host where it has to be run.
+$CL = new PerlACE::Process ("client", $host);
+
+$SV->Spawn ();
+
+$client = $CL->SpawnWaitKill (300);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$server = $SV->WaitKill (10);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+unlink $iorfile;
+
+exit $status;
diff --git a/ACE/tests/HTBP/Send_Large_Msg/server.cpp b/ACE/tests/HTBP/Send_Large_Msg/server.cpp
new file mode 100644
index 00000000000..7b7f51cf1b9
--- /dev/null
+++ b/ACE/tests/HTBP/Send_Large_Msg/server.cpp
@@ -0,0 +1,103 @@
+// $Id$
+
+#include "tests/test_config.h"
+
+#include "ace/Log_Msg.h"
+
+#include "ace/HTBP/HTBP_Session.h"
+#include "ace/HTBP/HTBP_Stream.h"
+#include "ace/HTBP/HTBP_Addr.h"
+
+#include "ace/SOCK_Acceptor.h"
+#include "ace/SOCK_Stream.h"
+
+const size_t Send_Size = 4*1024;
+const size_t Loops = 10;
+const size_t Total_Size = Send_Size * Loops;
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+
+ ACE_UNUSED_ARG (argc);
+ ACE_UNUSED_ARG (argv);
+
+ char buffer[1000];
+
+ ACE_OS::socket_init (ACE_WSOCK_VERSION);
+
+ ACE_INET_Addr local(8088);
+ ACE_SOCK_Stream sock[2];
+ ACE_SOCK_Acceptor acc(local,1);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("server is ready\n")));
+
+ acc.accept(sock[0]);
+ ACE::HTBP::Channel channel1(sock[0]);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Got sock[0], handle = %d\n"),
+ sock[0].get_handle()));
+ acc.accept(sock[1]);
+ ACE::HTBP::Channel channel2(sock[1]);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Got sock[1], handle = %d\n"),
+ sock[1].get_handle()));
+ int res = 0;
+ while ((res =channel1.pre_recv()) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("res = %d. waiting 1 sec. %p\n"),
+ res,
+ ACE_TEXT("stream.pre_recv()")));
+ ACE_OS::sleep (1);
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Read from channel2\n")));
+ while ((res = channel2.pre_recv()) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("res = %d, waiting 1 sec. %p\n"),
+ res,
+ ACE_TEXT("stream2.pre_recv()")));
+ ACE_OS::sleep (1);
+ }
+
+ ACE::HTBP::Session *session = channel1.session();
+ ACE::HTBP::Stream stream (session);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("using streams %d, %d. Got sesssion = %x\n"),
+ sock[0].get_handle(),sock[1].get_handle(),session));
+
+ ssize_t got = 1;
+ ssize_t total_recv = 0;
+
+ while (got != 0)
+ {
+ errno = 0;
+ got = stream.recv (buffer, sizeof (buffer));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("got : %s %d "), buffer, got));
+
+ if (got < 0)
+ break;
+ total_recv += got;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("received %d, %s\n"),total_recv,buffer));
+
+
+ ACE_OS::strcpy (buffer,"I hear you !");
+ ssize_t n = stream.send (buffer,ACE_OS::strlen(buffer)+1);
+ if (n == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT("%p\n"),
+ ACE_TEXT("stream.send")),-1);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("send returned %d\n"),n));
+ return 0;
+
+}