summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-10 00:06:30 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-10 00:06:30 +0000
commit5b289d194bb93cda55f6ca875b28bd244c423ebf (patch)
treece5a6138f080446ab83584240453558fc8db4a08 /examples
parentf9a37b4a5604160c9169c7a2b19033b010a19bd4 (diff)
downloadATCD-5b289d194bb93cda55f6ca875b28bd244c423ebf.tar.gz
ChangeLogTag:Mon Oct 09 16:45:00 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'examples')
-rw-r--r--examples/RMCast/Makefile21
-rw-r--r--examples/RMCast/Send_File/Makefile37
-rw-r--r--examples/RMCast/Send_File/Receiver.cpp137
-rw-r--r--examples/RMCast/Send_File/Receiver.dsp96
-rw-r--r--examples/RMCast/Send_File/Send_File.dsw41
-rw-r--r--examples/RMCast/Send_File/Sender.cpp115
-rw-r--r--examples/RMCast/Send_File/Sender.dsp96
7 files changed, 543 insertions, 0 deletions
diff --git a/examples/RMCast/Makefile b/examples/RMCast/Makefile
new file mode 100644
index 00000000000..28d90c0fd31
--- /dev/null
+++ b/examples/RMCast/Makefile
@@ -0,0 +1,21 @@
+#----------------------------------------------------------------------------
+#
+# $Id$
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+DIRS = Send_File
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nolocal.GNU
diff --git a/examples/RMCast/Send_File/Makefile b/examples/RMCast/Send_File/Makefile
new file mode 100644
index 00000000000..9ec83518af5
--- /dev/null
+++ b/examples/RMCast/Send_File/Makefile
@@ -0,0 +1,37 @@
+#----------------------------------------------------------------------------
+#
+# $Id$
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+BIN = Sender \
+ Receiver
+
+PSRC=$(addsuffix .cpp,$(BIN))
+LDLIBS = -lACE_RMCast
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/examples/RMCast/Send_File/Receiver.cpp b/examples/RMCast/Send_File/Receiver.cpp
new file mode 100644
index 00000000000..0b4455f6935
--- /dev/null
+++ b/examples/RMCast/Send_File/Receiver.cpp
@@ -0,0 +1,137 @@
+// $Id$
+
+#include "ace/RMCast/RMCast_UDP_Reliable_Receiver.h"
+#include "ace/INET_Addr.h"
+#include "ace/FILE_IO.h"
+#include "ace/Message_Block.h"
+
+ACE_RCSID(tests, RMCast_Examples_Receiver, "$Id$")
+
+class File_Module : public ACE_RMCast_Module
+{
+public:
+ File_Module (void);
+
+ /// Return 1 if all the data has been received
+ int all_received (void) const;
+
+ /// Initialize the module
+ int open (const char *filename);
+
+ int close (void);
+ int data (ACE_RMCast::Data &data);
+
+private:
+ /// Set to 1 when the last block is received
+ int all_received_;
+
+ /// Used to dump the received data into a file
+ ACE_FILE_IO file_io_;
+};
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s <filename> <mcastgroup:port>\n",
+ argv[0]),
+ 1);
+ }
+
+ const char *filename = argv[1];
+
+ File_Module file_module;
+ if (file_module.open (filename) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open file module\n"),
+ 1);
+ }
+
+ ACE_RMCast_UDP_Reliable_Receiver receiver (&file_module);
+
+ ACE_INET_Addr mcast_group;
+ if (mcast_group.set (argv[2]) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot read file <%s>\n", filename),
+ 1);
+ }
+
+ if (receiver.open (mcast_group) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open UDP I/O at <%s:%d> %p\n",
+ mcast_group.get_host_name (),
+ mcast_group.get_port_number (),
+ ""),
+ 1);
+ }
+
+ // Use the Reactor to demultiplex all the messages
+ ACE_Reactor *reactor = ACE_Reactor::instance ();
+ receiver.reactive_incoming_messages (reactor);
+
+ // Wait until all the messages are successfully delivered
+ do
+ {
+ // Try for 50 milliseconds...
+ ACE_Time_Value tv(0, 50000);
+ int r = reactor->handle_events (&tv);
+ if (r == -1)
+ break;
+ }
+ while (file_module.all_received () == 0);
+
+ (void) file_module.close ();
+
+ return 0;
+}
+
+// ****************************************************************
+
+File_Module::File_Module (void)
+ : all_received_ (0)
+{
+}
+
+int
+File_Module::all_received (void) const
+{
+ return this->all_received_;
+}
+
+int
+File_Module::open (const char * filename)
+{
+ ACE_HANDLE handle = ACE_OS::open (filename, O_WRONLY|O_BINARY|O_CREAT);
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open file <%s> %p\n", filename, ""),
+ -1);
+ }
+ this->file_io_.set_handle (handle);
+ return 0;
+}
+
+int
+File_Module::close (void)
+{
+ (void) this->file_io_.close ();
+ return 0;
+}
+
+int
+File_Module::data (ACE_RMCast::Data &data)
+{
+ size_t length = data.payload->length () - 1;
+ (void) this->file_io_.send (data.payload->rd_ptr () + 1, length);
+
+ if (*(data.payload->rd_ptr ()) == 'E')
+ this->all_received_ = 1;
+
+ return 0;
+}
diff --git a/examples/RMCast/Send_File/Receiver.dsp b/examples/RMCast/Send_File/Receiver.dsp
new file mode 100644
index 00000000000..95716f963e0
--- /dev/null
+++ b/examples/RMCast/Send_File/Receiver.dsp
@@ -0,0 +1,96 @@
+# Microsoft Developer Studio Project File - Name="Receiver" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Receiver - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Receiver.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Receiver.mak" CFG="Receiver - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Receiver - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Receiver - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Receiver - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib ACE_RMCast.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\ace" /libpath:"..\..\..\ace\RMCast"
+
+!ELSEIF "$(CFG)" == "Receiver - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ACE_RMCastd.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /out:"Receiver.exe" /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\..\ace\RMCast"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Receiver - Win32 Release"
+# Name "Receiver - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Receiver.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/examples/RMCast/Send_File/Send_File.dsw b/examples/RMCast/Send_File/Send_File.dsw
new file mode 100644
index 00000000000..6d82e53bde4
--- /dev/null
+++ b/examples/RMCast/Send_File/Send_File.dsw
@@ -0,0 +1,41 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Receiver"=.\Receiver.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Sender"=.\Sender.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/examples/RMCast/Send_File/Sender.cpp b/examples/RMCast/Send_File/Sender.cpp
new file mode 100644
index 00000000000..5c065db9f67
--- /dev/null
+++ b/examples/RMCast/Send_File/Sender.cpp
@@ -0,0 +1,115 @@
+// $Id$
+
+#include "ace/RMCast/RMCast_UDP_Reliable_Sender.h"
+#include "ace/INET_Addr.h"
+#include "ace/FILE_IO.h"
+#include "ace/Message_Block.h"
+
+ACE_RCSID(tests, RMCast_Examples_Sender, "$Id$")
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s <filename> <mcastgroup:port>\n",
+ argv[0]),
+ 1);
+ }
+
+ const char *filename = argv[1];
+ if (ACE_OS::access (filename, R_OK) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot read file <%s>\n", filename),
+ 1);
+ }
+
+ ACE_INET_Addr mcast_group;
+ if (mcast_group.set (argv[2]) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot read file <%s>\n", filename),
+ 1);
+ }
+
+
+ ACE_HANDLE handle = ACE_OS::open (filename, O_RDONLY|O_BINARY);
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open file <%s> %p\n", filename, ""),
+ 1);
+ }
+ ACE_FILE_IO file_io;
+ file_io.set_handle (handle);
+
+ // We don't provide a module to receive the control messages, in
+ // this example we simply ignore them.
+ ACE_RMCast_UDP_Reliable_Sender sender (0);
+
+ if (sender.open (mcast_group) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open UDP I/O at <%s:%d> %p\n",
+ mcast_group.get_host_name (),
+ mcast_group.get_port_number (),
+ ""),
+ 1);
+ }
+
+ // Use the Reactor to demultiplex all the messages
+ ACE_Reactor *reactor = ACE_Reactor::instance ();
+
+ sender.reactive_incoming_messages (reactor);
+ {
+ // Resend the messages every 20 milliseconds..
+ ACE_Time_Value tv (0, 20000);
+ sender.reactive_resends (reactor, tv);
+ }
+
+ for (;;)
+ {
+ ACE_Message_Block payload (BUFSIZ + 1);
+
+ ssize_t r = file_io.recv (payload.rd_ptr () + 1, BUFSIZ);
+ if (r <= 0)
+ break;
+
+ payload.wr_ptr (r + 1);
+ *(payload.rd_ptr ()) = 'N'; // Normal
+ if (r < BUFSIZ)
+ {
+ *(payload.rd_ptr ()) = 'E'; // EOF
+ }
+
+ ACE_RMCast::Data data;
+ data.payload = &payload;
+ if (sender.data (data) != 0)
+ break;
+
+ if (r < BUFSIZ)
+ {
+ // Last buffer, terminate loop
+ break;
+ }
+
+ // Handle incoming events, without blocking...
+ ACE_Time_Value tv (0);
+ reactor->handle_events (&tv);
+ }
+
+ // Wait until all the messages are successfully delivered
+ do
+ {
+ // Try for 50 milliseconds...
+ ACE_Time_Value tv(0, 50000);
+ int r = reactor->handle_events (&tv);
+ if (r == -1)
+ break;
+ }
+ while (sender.has_data ());
+
+ return 0;
+}
diff --git a/examples/RMCast/Send_File/Sender.dsp b/examples/RMCast/Send_File/Sender.dsp
new file mode 100644
index 00000000000..988ab9b4cd7
--- /dev/null
+++ b/examples/RMCast/Send_File/Sender.dsp
@@ -0,0 +1,96 @@
+# Microsoft Developer Studio Project File - Name="Sender" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Sender - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Sender.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Sender.mak" CFG="Sender - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Sender - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Sender - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Sender - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib ACE_RMCast.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\ace" /libpath:"..\..\..\ace\RMCast"
+
+!ELSEIF "$(CFG)" == "Sender - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ACE_RMCastd.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /out:"Sender.exe" /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\..\ace\RMCast"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Sender - Win32 Release"
+# Name "Sender - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Sender.cpp
+# End Source File
+# End Group
+# End Target
+# End Project