summaryrefslogtreecommitdiff
path: root/examples/Reactor/Multicast
diff options
context:
space:
mode:
Diffstat (limited to 'examples/Reactor/Multicast')
-rw-r--r--examples/Reactor/Multicast/Log_Wrapper.cpp72
-rw-r--r--examples/Reactor/Multicast/Log_Wrapper.h68
-rw-r--r--examples/Reactor/Multicast/Makefile91
-rw-r--r--examples/Reactor/Multicast/Makefile.bor8
-rw-r--r--examples/Reactor/Multicast/Multicast.dsw41
-rw-r--r--examples/Reactor/Multicast/README15
-rw-r--r--examples/Reactor/Multicast/client.bor19
-rw-r--r--examples/Reactor/Multicast/client.cpp121
-rw-r--r--examples/Reactor/Multicast/client.dsp96
-rw-r--r--examples/Reactor/Multicast/server.bor19
-rw-r--r--examples/Reactor/Multicast/server.cpp243
-rw-r--r--examples/Reactor/Multicast/server.dsp96
12 files changed, 0 insertions, 889 deletions
diff --git a/examples/Reactor/Multicast/Log_Wrapper.cpp b/examples/Reactor/Multicast/Log_Wrapper.cpp
deleted file mode 100644
index 94f3361a597..00000000000
--- a/examples/Reactor/Multicast/Log_Wrapper.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// $Id$
-
-// client.C
-
-#include "Log_Wrapper.h"
-
-ACE_RCSID(Multicast, Log_Wrapper, "$Id$")
-
-Log_Wrapper::Log_Wrapper (void)
-{
- sequence_number_ = 0;
- this->log_msg_.app_id = ACE_OS::getpid ();
-}
-
-Log_Wrapper::~Log_Wrapper (void)
-{
-}
-
-// Set the log_msg_ host address.
-
-int
-Log_Wrapper::open (const int port, const char *mcast_addr)
-{
- struct hostent *host_info;
- ACE_utsname host_data;
-
- if (ACE_OS::uname (&host_data) < 0)
- return -1;
-
- if ((host_info = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR(host_data.nodename))) == NULL)
- return -1;
- else
- ACE_OS::memcpy ((char *) &this->log_msg_.host,
- (char *) host_info->h_addr,
- host_info->h_length);
-
- // This starts out initialized to all zeros!
- server_ = ACE_INET_Addr (port, mcast_addr);
-
- if (logger_.subscribe (server_) == -1)
- perror("can't subscribe to multicast group"), exit(1);
-
- // success.
- return 0;
-}
-
-// Send the message to a logger object.
-// This wrapper fills in all the log_record info for you.
-// uses iovector stuff to make contiguous header and message.
-
-int
-Log_Wrapper::log_message (Log_Priority type, char *message)
-{
- sequence_number_++;
-
- this->log_msg_.type = type;
- this->log_msg_.time = time (0);
- this->log_msg_.msg_length = strlen(message)+1;
- this->log_msg_.sequence_number = htonl(sequence_number_);
-
- iovec iovp[2];
- iovp[0].iov_base = ACE_reinterpret_cast (char*, &log_msg_);
- iovp[0].iov_len = sizeof (log_msg_);
- iovp[1].iov_base = message;
- iovp[1].iov_len = log_msg_.msg_length;
-
- logger_.send (iovp, 2);
-
- // success.
- return 0;
-}
-
diff --git a/examples/Reactor/Multicast/Log_Wrapper.h b/examples/Reactor/Multicast/Log_Wrapper.h
deleted file mode 100644
index 10458f706bc..00000000000
--- a/examples/Reactor/Multicast/Log_Wrapper.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- C++ -*- */
-// $Id$
-
-// log_wrapper.h
-
-#include "ace/Profile_Timer.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/INET_Addr.h"
-#include "ace/SOCK_Dgram_Mcast.h"
-
-#ifndef _LOG_WRAPPER_H
-#define _LOG_WRAPPER_H
-
-class Log_Wrapper
- // = TITLE
- // Provide a wrapper around sending log messages via IP
- // multicast.
-{
-public:
- Log_Wrapper (void);
- ~Log_Wrapper (void);
-
- // = Types of logging messages.
- enum Log_Priority
- {
- LM_MESSAGE,
- LM_DEBUG,
- LM_WARNING,
- LM_ERROR,
- LM_EMERG
- };
-
- int open (const int port, const char* mcast_addr);
- // Subscribe to a given UDP multicast group
-
- int log_message (Log_Priority type, char *message);
- // send a string to the logger
-
- // = Format of the logging record.
- struct Log_Record
- {
- u_long sequence_number;
- Log_Priority type;
- long host;
- long time;
- long app_id;
- long msg_length;
- };
-
-private:
- ACE_INET_Addr server_;
- // Server address where records are logged.
-
- u_long sequence_number_;
- // Keep track of the sequence.
-
- Log_Record log_msg_;
- // One record used for many log messages.
-
- ACE_SOCK_Dgram_Mcast logger_;
- // A logger object.
-};
-
-#endif /* _LOG_WRAPPER_H */
diff --git a/examples/Reactor/Multicast/Makefile b/examples/Reactor/Multicast/Makefile
deleted file mode 100644
index 3af537370be..00000000000
--- a/examples/Reactor/Multicast/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-#----------------------------------------------------------------------------
-#
-# $Id$
-#
-# Makefile for the Reactor multicast tests
-#----------------------------------------------------------------------------
-
-#----------------------------------------------------------------------------
-# Local macros
-#----------------------------------------------------------------------------
-
-BIN = client server
-
-FILES = Log_Wrapper
-
-SRC = $(addsuffix .cpp,$(FILES))
-OBJ = $(addsuffix .o,$(FILES))
-
-BUILD = $(VBIN)
-
-#----------------------------------------------------------------------------
-# ACE stuff
-#----------------------------------------------------------------------------
-
-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.
-
-
-.obj/Log_Wrapper.o .obj/Log_Wrapper.so .shobj/Log_Wrapper.o .shobj/Log_Wrapper.so: Log_Wrapper.cpp Log_Wrapper.h \
- $(ACE_ROOT)/ace/Profile_Timer.h \
- $(ACE_ROOT)/ace/pre.h \
- $(ACE_ROOT)/ace/post.h \
- $(ACE_ROOT)/ace/ace_wchar.h \
- $(ACE_ROOT)/ace/ace_wchar.inl \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/OS_Dirent.h \
- $(ACE_ROOT)/ace/OS_Export.h \
- $(ACE_ROOT)/ace/OS_Errno.h \
- $(ACE_ROOT)/ace/OS_Errno.inl \
- $(ACE_ROOT)/ace/OS_Dirent.inl \
- $(ACE_ROOT)/ace/OS_String.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/ACE_export.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS_String.inl \
- $(ACE_ROOT)/ace/OS_Memory.h \
- $(ACE_ROOT)/ace/OS_Memory.inl \
- $(ACE_ROOT)/ace/OS_TLI.h \
- $(ACE_ROOT)/ace/OS_TLI.inl \
- $(ACE_ROOT)/ace/Time_Value.h \
- $(ACE_ROOT)/ace/Time_Value.inl \
- $(ACE_ROOT)/ace/Default_Constants.h \
- $(ACE_ROOT)/ace/Global_Macros.h \
- $(ACE_ROOT)/ace/Min_Max.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Trace.h $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/High_Res_Timer.h \
- $(ACE_ROOT)/ace/High_Res_Timer.i \
- $(ACE_ROOT)/ace/Profile_Timer.i \
- $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/Sock_Connect.h \
- $(ACE_ROOT)/ace/Sock_Connect.i \
- $(ACE_ROOT)/ace/Addr.h $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/INET_Addr.i \
- $(ACE_ROOT)/ace/SOCK_Dgram_Mcast.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/Flag_Manip.h \
- $(ACE_ROOT)/ace/Flag_Manip.i \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i \
- $(ACE_ROOT)/ace/SOCK_Dgram_Mcast.i
-
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/examples/Reactor/Multicast/Makefile.bor b/examples/Reactor/Multicast/Makefile.bor
deleted file mode 100644
index dbb2124279b..00000000000
--- a/examples/Reactor/Multicast/Makefile.bor
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Makefile for building the Multicast example
-#
-
-MAKEFILES = client.bor server.bor
-
-!include <$(ACE_ROOT)\include\makeinclude\recurse.bor>
-
diff --git a/examples/Reactor/Multicast/Multicast.dsw b/examples/Reactor/Multicast/Multicast.dsw
deleted file mode 100644
index d17cf7c9604..00000000000
--- a/examples/Reactor/Multicast/Multicast.dsw
+++ /dev/null
@@ -1,41 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "client"=.\client.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "server"=.\server.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/examples/Reactor/Multicast/README b/examples/Reactor/Multicast/README
deleted file mode 100644
index 85f64cc8120..00000000000
--- a/examples/Reactor/Multicast/README
+++ /dev/null
@@ -1,15 +0,0 @@
-The following test illustrates the SOCK Mcast multicast wrappers in
-conjunction with the Reactor. This test was written by Tim Harrison
-(harrison@cs.wustl.edu).
-
-To run the server type:
-
-% server &
-
-It will wait for the first message sent to it and then read for 5 seconds.
-
-To run the client type any of these:
-
-% client -m max_message_size -i iterations
-% client < <filename>
-% client
diff --git a/examples/Reactor/Multicast/client.bor b/examples/Reactor/Multicast/client.bor
deleted file mode 100644
index 5a22ed442b8..00000000000
--- a/examples/Reactor/Multicast/client.bor
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for building the multicast client
-#
-
-NAME = client
-
-OBJFILES = \
- $(OBJDIR)\Log_Wrapper.obj \
- $(OBJDIR)\client.obj
-
-CPPDIR = .
-
-LIBFILES = \
- $(ACE_LIB)
-
-CFLAGS = $(ACE_CFLAGS)
-
-!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor>
-
diff --git a/examples/Reactor/Multicast/client.cpp b/examples/Reactor/Multicast/client.cpp
deleted file mode 100644
index 4ffc8fc5ecb..00000000000
--- a/examples/Reactor/Multicast/client.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-// $Id$
-
-// This program reads in messages from stdin and sends them to a
-// Log_Wrapper.
-
-#include "ace/Get_Opt.h"
-#include "ace/Log_Msg.h"
-#include "Log_Wrapper.h"
-
-ACE_RCSID(Multicast, client, "$Id$")
-
-// Multi-cast address.
-static const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR;
-
-// UDP port.
-static const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT;
-
-// Maximum message size.
-static int max_message_size = BUFSIZ;
-
-// Number of times to send message of max_message_size.
-static int iterations = 0;
-
-static void
-parse_args (int argc, ACE_TCHAR *argv[])
-{
- ACE_LOG_MSG->open (argv[0]);
-
- // Start at argv[1]
- ACE_Get_Opt getopt (argc, argv, ACE_TEXT("m:ui:"), 1);
-
- for (int c; (c = getopt ()) != -1; )
- switch (c)
- {
- case 'm':
- max_message_size = ACE_OS::atoi (getopt.opt_arg ()) * BUFSIZ;
- break;
- case 'i':
- iterations = ACE_OS::atoi (getopt.opt_arg ());
- break;
- case 'u':
- // usage fallthrough
- default:
- ACE_ERROR ((LM_ERROR,
- "%n: -m max_message_size (in k) -i iterations\n%a",
- 1));
- /* NOTREACHED */
- }
-}
-
-int
-ACE_TMAIN (int argc, ACE_TCHAR **argv)
-{
- int user_prompt;
-
- parse_args (argc,argv);
-
- ACE_DEBUG ((LM_DEBUG, "max buffer size = %d\n", max_message_size));
-
- // Instantiate a log wrapper for logging
- Log_Wrapper log;
-
- // Make a connection to a logger.
- if (log.open (UDP_PORT, MCAST_ADDR) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n" "open"), -1);
-
- char *buf;
- ACE_NEW_RETURN (buf, char[max_message_size], -1);
-
- // If -i has been specified, send max_message_size messages
- // iterations number of times.
- if (iterations)
- {
- ACE_OS::memset (buf, 1, max_message_size);
-
- while (iterations--)
- if (log.log_message (Log_Wrapper::LM_DEBUG, buf) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n" "log"), -1);
- }
-
- // otherwise, a file has been redirected, or give prompts
- else
- {
- // If a file has been redirected, don't activate user prompts.
- if (ACE_OS::isatty (0))
- user_prompt = 1;
- else
- user_prompt = 0;
-
- // Continually read messages from stdin and log them.
-
- for (int count = 1;;)
- {
- if (user_prompt)
- ACE_DEBUG ((LM_DEBUG, "\nEnter message ('Q':quit):\n"));
-
- ssize_t nbytes = ACE_OS::read (ACE_STDIN, buf, max_message_size);
-
- if (nbytes <= 0)
- break; // End of file or error.
- buf[nbytes - 1] = '\0';
-
- // Quitting?
- if (user_prompt)
- {
- if (buf[0] == 'Q' || buf[0] == 'q')
- break;
- }
- else // Keep from overrunning the receiver.
- ACE_OS::sleep (1);
-
- // Send the message to the logger.
- if (log.log_message (Log_Wrapper::LM_DEBUG, buf) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n" "log_message"), -1);
- ACE_DEBUG ((LM_DEBUG, "finished sending message %d\n", count++));
- }
- }
-
- ACE_DEBUG ((LM_DEBUG, "Client done.\n"));
- return 0;
-}
diff --git a/examples/Reactor/Multicast/client.dsp b/examples/Reactor/Multicast/client.dsp
deleted file mode 100644
index c4e2ed8ca6d..00000000000
--- a/examples/Reactor/Multicast/client.dsp
+++ /dev/null
@@ -1,96 +0,0 @@
-# Microsoft Developer Studio Project File - Name="client" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=client - 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 "client.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 "client.mak" CFG="client - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "client - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "client - 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)" == "client - 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 ""
-# 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 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../ace"
-
-!ELSEIF "$(CFG)" == "client - 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 ""
-# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "client - Win32 Release"
-# Name "client - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\client.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Log_Wrapper.cpp
-# End Source File
-# End Target
-# End Project
diff --git a/examples/Reactor/Multicast/server.bor b/examples/Reactor/Multicast/server.bor
deleted file mode 100644
index 1260bbc21a8..00000000000
--- a/examples/Reactor/Multicast/server.bor
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for building the Multicast server
-#
-
-NAME = server
-
-OBJFILES = \
- $(OBJDIR)\Log_Wrapper.obj \
- $(OBJDIR)\server.obj
-
-CPPDIR = .
-
-LIBFILES = \
- $(ACE_LIB)
-
-CFLAGS = $(ACE_CFLAGS)
-
-!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor>
-
diff --git a/examples/Reactor/Multicast/server.cpp b/examples/Reactor/Multicast/server.cpp
deleted file mode 100644
index 337b07aca36..00000000000
--- a/examples/Reactor/Multicast/server.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-// $Id$
-
-// server.cpp (written by Tim Harrison)
-
-// Listens to multicast address for client log messages. Prints
-// Mbits/sec received from client.
-
-#include "ace/SOCK_Dgram.h"
-#include "ace/INET_Addr.h"
-#include "ace/SOCK_Dgram_Mcast.h"
-#include "ace/Reactor.h"
-#include "ace/Log_Msg.h"
-#include "Log_Wrapper.h"
-
-ACE_RCSID(Multicast, server, "$Id$")
-
-#if defined (ACE_HAS_IP_MULTICAST)
-class Server_Events : public ACE_Event_Handler
-{
-public:
- Server_Events (u_short port,
- const char *mcast_addr,
- long time_interval = 0);
- ~Server_Events (void);
-
- virtual int handle_input (ACE_HANDLE fd);
- virtual int handle_timeout (const ACE_Time_Value &tv,
- const void *arg);
-
- virtual ACE_HANDLE get_handle (void) const;
-
- ACE_Time_Value *wait_time (void);
-
-private:
- char *message_;
- Log_Wrapper::Log_Record *log_record_;
- char buf_[4 * BUFSIZ];
- char hostname_[MAXHOSTNAMELEN];
-
- int initialized_;
- int count_;
- int interval_;
- // time interval to log messages
-
- ACE_Time_Value *how_long_;
- ACE_Reactor *reactor_;
- ACE_SOCK_Dgram_Mcast mcast_dgram_;
- ACE_INET_Addr remote_addr_;
- ACE_INET_Addr mcast_addr_;
-
- // = statistics on messages received
- double total_bytes_received_;
- int total_messages_received_;
- int last_sequence_number_;
-};
-
-static const char MCAST_ADDR[] = ACE_DEFAULT_MULTICAST_ADDR;
-static const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT;
-static const int DURATION = 5;
-
-ACE_HANDLE
-Server_Events::get_handle (void) const
-{
- return this->mcast_dgram_.get_handle ();
-}
-
-ACE_Time_Value *
-Server_Events::wait_time (void)
-{
- return this->how_long_;
-}
-
-Server_Events::Server_Events (u_short port,
- const char *mcast_addr,
- long time_interval)
- : initialized_ (0),
- count_ (1),
- interval_ (time_interval),
- mcast_addr_ (port, mcast_addr),
- total_bytes_received_ (0)
-{
- // Use ACE_SOCK_Dgram_Mcast factory to subscribe to multicast group.
-
- if (ACE_OS::hostname (this->hostname_,
- MAXHOSTNAMELEN) == -1)
- ACE_ERROR ((LM_ERROR,
- "%p\n",
- "hostname"));
-
- else if (this->mcast_dgram_.subscribe (this->mcast_addr_) == -1)
- ACE_ERROR ((LM_ERROR,
- "%p\n",
- "subscribe"));
- else
- {
- // Point to NULL so that we block in the beginning.
- this->how_long_ = 0;
-
- this->log_record_ = (Log_Wrapper::Log_Record *) &buf_;
- this->message_ = &buf_[sizeof (Log_Wrapper::Log_Record)];
- }
-}
-
-// A destructor that emacs refuses to color blue ;-)
-
-Server_Events::~Server_Events (void)
-{
- this->mcast_dgram_.unsubscribe ();
-
- ACE_DEBUG ((LM_DEBUG,
- "total bytes received = %d after %d second\n",
- this->total_bytes_received_,
- this->interval_));
-
- ACE_DEBUG ((LM_DEBUG,
- "Mbits/sec = %.2f\n",
- (float) (total_bytes_received_ * 8 / (float) (1024*1024*interval_))));
-
- ACE_DEBUG ((LM_DEBUG,
- "last sequence number = %d\ntotal messages received = %d\ndiff = %d\n",
- this->last_sequence_number_,
- this->total_messages_received_,
- this->last_sequence_number_ - total_messages_received_));
-}
-
-int
-Server_Events::handle_timeout (const ACE_Time_Value &,
- const void *arg)
-{
- ACE_DEBUG ((LM_DEBUG, "\t%d timeout%s occurred for %s.\n",
- this->count_,
- this->count_ == 1 ? "" : "s",
- (char *) arg));
-
- // Don't let the timeouts continue if there's no activity since
- // otherwise we use up a lot of CPU time unnecessarily.
- if (this->count_ == 5)
- {
- reactor ()->cancel_timer (this);
- this->initialized_ = 0;
-
- ACE_DEBUG ((LM_DEBUG,
- "\tcancelled timeout for %s to avoid busy waiting.\n",
- (char *) arg));
- }
-
- this->count_++;
- return 0;
-}
-
-int
-Server_Events::handle_input (ACE_HANDLE)
-{
- // Receive message from multicast group.
- iovec iovp[2];
- iovp[0].iov_base = buf_;
- iovp[0].iov_len = sizeof (log_record_);
- iovp[1].iov_base = &buf_[sizeof (log_record_)];
- iovp[1].iov_len = 4 * BUFSIZ - sizeof (log_record_);
-
- ssize_t retcode =
- this->mcast_dgram_.recv (iovp,
- 2,
- this->remote_addr_);
- if (retcode != -1)
- {
- total_messages_received_++;
- total_bytes_received_ += retcode;
- last_sequence_number_ =
- ntohl (log_record_->sequence_number);
-
- for (char *message_end = this->message_ + ACE_OS::strlen (this->message_) - 1;
- ACE_OS::strchr ("\r\n \t", *message_end) != 0;
- )
- {
- *message_end-- = '\0';
- if (message_end == this->message_)
- break;
- }
-
- ACE_DEBUG ((LM_DEBUG,
- "sequence number = %d\n",
- last_sequence_number_));
- ACE_DEBUG ((LM_DEBUG,
- "message = '%s'\n",
- this->message_));
-
- if (this->initialized_ == 0)
- {
- // Restart the timer since we've received events again.
- if (reactor()->schedule_timer (this,
- (void *) this->hostname_,
- ACE_Time_Value::zero,
- ACE_Time_Value (DURATION)) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "schedule_timer"),
- -1);
- this->initialized_ = 1;
- }
-
- this->count_ = 1;
- return 0;
- }
- else
- return -1;
-}
-
-int
-ACE_TMAIN (int, ACE_TCHAR *[])
-{
- // Instantiate a server which will receive messages for DURATION
- // seconds.
- Server_Events server_events (UDP_PORT,
- MCAST_ADDR,
- DURATION);
- // Instance of the ACE_Reactor.
- ACE_Reactor reactor;
-
- if (reactor.register_handler (&server_events,
- ACE_Event_Handler::READ_MASK) == -1)
- ACE_ERROR ((LM_ERROR,
- "%p\n%a",
- "register_handler",
- 1));
-
- ACE_DEBUG ((LM_DEBUG,
- "starting up server\n"));
-
- for (;;)
- reactor.handle_events (server_events.wait_time ());
-
- ACE_NOTREACHED (return 0;)
-}
-#else
-int
-main (int, char *argv[])
-{
- ACE_ERROR_RETURN ((LM_ERROR,
- "error: %s must be run on a platform that support IP multicast\n",
- argv[0]), -1);
-}
-#endif /* ACE_HAS_IP_MULTICAST */
diff --git a/examples/Reactor/Multicast/server.dsp b/examples/Reactor/Multicast/server.dsp
deleted file mode 100644
index 0caca524222..00000000000
--- a/examples/Reactor/Multicast/server.dsp
+++ /dev/null
@@ -1,96 +0,0 @@
-# Microsoft Developer Studio Project File - Name="server" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=server - 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 "server.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 "server.mak" CFG="server - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "server - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "server - 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)" == "server - 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 ""
-# 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 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../ace"
-
-!ELSEIF "$(CFG)" == "server - 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 ""
-# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "server - Win32 Release"
-# Name "server - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\Log_Wrapper.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\server.cpp
-# End Source File
-# End Target
-# End Project