summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-01-17 19:51:07 +0000
committerjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-01-17 19:51:07 +0000
commit7db238cd280f01557b73730dbc156d02bb904626 (patch)
tree705e9eaf9c84ad4b7ff12a21adbcaea12eae9fcd
parent24d081079749154064ee04317c074198baf4e741 (diff)
downloadATCD-7db238cd280f01557b73730dbc156d02bb904626.tar.gz
*** empty log message ***
-rw-r--r--ChangeLog-99b24
-rw-r--r--docs/tutorials/001/Makefile11
-rw-r--r--docs/tutorials/001/combine.shar574
-rw-r--r--docs/tutorials/001/page01.html13
-rw-r--r--docs/tutorials/001/page02.html187
-rw-r--r--docs/tutorials/001/page03.html146
-rw-r--r--docs/tutorials/001/page04.html157
-rw-r--r--docs/tutorials/001/page05.html28
-rw-r--r--docs/tutorials/002/Makefile11
-rw-r--r--docs/tutorials/002/combine.shar328
-rw-r--r--docs/tutorials/002/page01.html25
-rw-r--r--docs/tutorials/002/page02.html136
-rw-r--r--docs/tutorials/002/page03.html136
-rw-r--r--docs/tutorials/002/page04.html11
-rw-r--r--docs/tutorials/003/Makefile13
-rw-r--r--docs/tutorials/003/client.cpp14
-rw-r--r--docs/tutorials/003/combine.shar217
-rw-r--r--docs/tutorials/003/page01.html94
-rw-r--r--docs/tutorials/004/Makefile13
-rw-r--r--docs/tutorials/004/combine.shar216
-rw-r--r--docs/tutorials/004/page01.html188
-rw-r--r--docs/tutorials/005/Makefile14
-rw-r--r--docs/tutorials/005/acceptor6
-rw-r--r--docs/tutorials/005/combine.shar423
-rw-r--r--docs/tutorials/005/fix.Makefile60
-rw-r--r--docs/tutorials/005/handler81
-rw-r--r--docs/tutorials/005/main36
-rw-r--r--docs/tutorials/005/page01.html9
-rw-r--r--docs/tutorials/005/page02.html304
-rw-r--r--docs/tutorials/005/page03.html112
-rw-r--r--docs/tutorials/005/page04.html85
-rw-r--r--docs/tutorials/005/page05.html153
-rw-r--r--docs/tutorials/005/page06.html288
-rw-r--r--docs/tutorials/005/page07.html174
-rw-r--r--docs/tutorials/005/page08.html12
-rw-r--r--docs/tutorials/006/fix.Makefile60
-rwxr-xr-xdocs/tutorials/007/fix.Makefile60
-rw-r--r--docs/tutorials/010/Makefile2
-rw-r--r--docs/tutorials/011/Makefile2
-rw-r--r--docs/tutorials/012/Makefile2
-rw-r--r--docs/tutorials/013/Makefile2
-rw-r--r--docs/tutorials/014/Makefile2
-rw-r--r--docs/tutorials/016/Makefile2
-rw-r--r--docs/tutorials/017/Makefile2
44 files changed, 2877 insertions, 1556 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index b83a92a9bdc..5988a9c625d 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,27 @@
+Sun Jan 17 14:42:39 1999 James CE Johnson <jcej@chiroptera.tragus.org>
+
+ * docs/tutorials/001/*:
+ * docs/tutorials/002/*:
+ * docs/tutorials/003/*:
+ * docs/tutorials/004/*:
+ * docs/tutorials/005/*:
+ Converted to the new (colorized) format used by T13 and beyond.
+ I will convert the remaining tutorials (6-12) as each is reviewed.
+
+ * docs/tutorials/005/fix.Makefile:
+ * docs/tutorials/006/fix.Makefile:
+ * docs/tutorials/007/fix.Makefile: Replaced by ../fix.Makefile.
+
+ * docs/tutorials/010/Makefile:
+ * docs/tutorials/011/Makefile:
+ * docs/tutorials/012/Makefile:
+ * docs/tutorials/013/Makefile:
+ * docs/tutorials/014/Makefile:
+ * docs/tutorials/016/Makefile:
+ * docs/tutorials/017/Makefile:
+ These all referenced ../007/fix.Makefile. They now reference
+ ../fix.Makefile instead.
+
Sun Jan 17 13:50:16 1999 James CE Johnson <jcej@chiroptera.tragus.org>
* docs/tutorials/002/handler.h:
diff --git a/docs/tutorials/001/Makefile b/docs/tutorials/001/Makefile
index 88cbcd3b69c..cf0d529e3ea 100644
--- a/docs/tutorials/001/Makefile
+++ b/docs/tutorials/001/Makefile
@@ -37,6 +37,17 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
# Local targets
#----------------------------------------------------------------------------
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre *.pst > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
diff --git a/docs/tutorials/001/combine.shar b/docs/tutorials/001/combine.shar
new file mode 100644
index 00000000000..8dcf0ab3f72
--- /dev/null
+++ b/docs/tutorials/001/combine.shar
@@ -0,0 +1,574 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 1999-01-17 14:14 EST by <jcej@chiroptera.tragus.org>.
+# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/001'.
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 524 -rw-rw-r-- hdr
+# 38 -rw-rw-r-- bodies
+# 4034 -rw-rw-r-- page01.pre
+# 2188 -rw-rw-r-- page02.pre
+# 553 -rw-rw-r-- page03.pre
+# 79 -rw-rw-r-- page04.pre
+# 1149 -rw-rw-r-- page05.pre
+# 478 -rw-rw-r-- page02.pst
+# 1434 -rw-rw-r-- page03.pst
+# 279 -rw-rw-r-- page04.pst
+#
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+touch -am 1231235999 $$.touch >/dev/null 2>&1
+if test ! -f 1231235999 && test -f $$.touch; then
+ shar_touch=touch
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 1231235999 $$.touch
+#
+if mkdir _sh00080; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= hdr ==============
+if test -f 'hdr' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'hdr' '(file already exists)'
+else
+ $echo 'x -' extracting 'hdr' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+X <TITLE>ACE Tutorial 001</TITLE>
+X <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
+X <META NAME="Author" CONTENT="James CE Johnson">
+X <META NAME="Description" CONTENT="A first step towards using ACE productively">
+</HEAD>
+<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
+X
+X
+<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
+A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
+X
+<hr>
+SHAR_EOF
+ $shar_touch -am 0117141099 'hdr' &&
+ chmod 0664 'hdr' ||
+ $echo 'restore of' 'hdr' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'hdr:' 'MD5 check failed'
+1d643c1c0995e071a0a9e3662d7a440b hdr
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
+ test 524 -eq "$shar_count" ||
+ $echo 'hdr:' 'original size' '524,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= bodies ==============
+if test -f 'bodies' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'bodies' '(file already exists)'
+else
+ $echo 'x -' extracting 'bodies' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
+PAGE=2
+server.cpp
+acceptor.h
+logger.h
+SHAR_EOF
+ $shar_touch -am 0117140699 'bodies' &&
+ chmod 0664 'bodies' ||
+ $echo 'restore of' 'bodies' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'bodies:' 'MD5 check failed'
+20ddb6c1ff71a6481ce0956f1a70a612 bodies
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
+ test 38 -eq "$shar_count" ||
+ $echo 'bodies:' 'original size' '38,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pre ==============
+if test -f 'page01.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
+<P>The purpose of this tutorial is to show you how to create a very simple
+server capable of handling multiple client connections. Unlike a &quot;traditional&quot;
+server application, this one handles all requests in one process. Issues
+of multi-processing and multi-threading will be handled in later tutorials.</P>
+X
+<P>
+<HR WIDTH="100%"></P>
+X
+<P>What do you need to create a server?</P>
+X
+<OL>
+<LI>Something which accepts connections from clients</LI>
+X
+<LI>Something which handles established connections</LI>
+X
+<LI>A main program loop that handles it all</LI>
+</OL>
+X
+<P>The ACE&nbsp;Acceptor provides a solution for our first requirement.
+This class is given a TCP/IP&nbsp;port number on which it will listen for
+incoming connections. When a connection is attempted, the acceptor will
+create a new object (the handler) to deal with the client connection while
+the acceptor goes back to listening for other connections.</P>
+X
+<P>The ACE&nbsp;EventHandler solves our second requirement. This doesn't
+seem obvious now but as we progress through this tutorial it will become
+more clear.</P>
+X
+<P>Finally, a simple <I>main()</I> function will provide our program loop.
+After any program initialization, it will enter an infinite loop which
+waits for connection attempts to the Acceptor or data &quot;events&quot;
+on the EventHandler.</P>
+X
+<P>
+<HR WIDTH="100%"></P>
+X
+<P>Before we continue, I need to introduce one more ACE concept: the Reactor.
+</P>
+X
+<P>I don't want to go into great detail at this time on what the Reactor
+is, what it does and how it does it but it is necessary for you to understand
+the basic function of a reactor because it is going to be in the first
+piece of code you see. The figure below depicts the interrelationships
+between the Reactor, the Acceptor and the application handler.</P>
+<P> <center> <img src="simple.gif" align=center> </center>
+X
+<P>Briefly:<BR>
+The reactor is an object which reacts when things happen to other objects.
+These things are called <I>events</I>. The <I>other objects</I> are communications
+objects which you have <I>registered</I> with the reactor. At the time
+of registration, you also specify which events you are interested in. The
+reactor is notified by the operating system when the events of interest
+occur within the registered objects. The reactor then uses member functions
+of the registered object to process the event. Notice that the reactor
+doesn't care what happens because of the event. It is the object's responsibility
+to process the event correctly. The reactor simply notifies the object
+of the event.</P>
+X
+<P>Why use the reactor?</P>
+X
+<P>That will become clear as the tutorial progresses. For now, however,
+a brief answer would be this: it allows multiple simultaneous client connections
+to be processed efficiently by a single-threaded server. </P>
+X
+<P>Servers have traditionally created a separate thread or process for
+each client served. For large-volume services (such as telnet and ftp)
+this is appropriate. However, for small-volume services the overhead of
+process creation far outweighs the actual work being done. So... folks
+begin using threads instead of processes to handle the clients. This is
+good also but still, in some cases, the overhead is too much to bear. Instead,
+why not have a single thread handle several clients and use a more intelligent
+load-balancing methodology than one-thread-or-process-per-client?
+<i>Caveat: Handling all requests in one thread of one process is really
+only good when the requests can be handled almost instantaneously.</i>
+</P>
+X
+<P>This is where the reactor's power and flexibility come into play. The
+developer can create a simple, single-threaded application that is later
+modified to thread-per-client, process-per-client or thread-pool solution.
+<P>
+If all of this is gibberish and makes you think that ACE is way to hard to
+learn, don't worry. We'll go into all the details and explain as we go.
+I only went into all of this so that it can kick around in the back of your
+mind until you need it later.
+<P>
+SHAR_EOF
+ $shar_touch -am 0117140899 'page01.pre' &&
+ chmod 0664 'page01.pre' ||
+ $echo 'restore of' 'page01.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pre:' 'MD5 check failed'
+58b12a93efda94c99be5d0b38c3096a5 page01.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
+ test 4034 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '4034,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page02.pre ==============
+if test -f 'page02.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page02.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page02.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page02.pre' &&
+<P>From here, we to move on to the main program loop. In a way, we're
+starting at the final product when we do this, but it is a very simple
+piece of code and a good place to start.
+X
+<P>The <A HREF="server.cpp">main</A>
+program is really quite simple. The real work is done in the ACE derived
+classes.
+X
+<P>
+Kirthika Parameswaran offers this abstract of Tutorial 1:
+<UL>
+<P>
+This is a simple logging server example.
+The Reactor is used to handle more than one client request using a
+single thread of execution instead of one thread per client. The Reactor
+reactes to events and demultiplexes the events to the appropriate
+Event_Handler registered with it, using the "callback" technique. The
+reactor runs in an infinte event loop handling all the incoming events.
+<P>
+The Logging_Acceptor listens at a SERVER PORT address and passively
+waits for requests to arrive. The Acceptor is also an Event_Handler and
+is registered with the Reactor. This way it is simply yet another
+Event_Handler for the Reactor and hence no special processing is needed
+for it.
+<P>
+Once a connection request occurs, the Acceptor accepts it and
+a connection is established. The reactor instance is passed to the
+handler so that it can register with the Reactor. It does so with an
+ACE_Event_Handler::ACCEPT_MASK.
+<P>
+The Logging_Client is another Event_Handler which actually handles the
+client requests in its handle_input() method. It is also registered
+with the Reactor with the ACE_Event_Handler::READ_MASK.
+<P>
+The Event_Handlers can be unregistered from the Reactor using
+handle_close() methods
+or explicitly calling the remove_handler() methods.
+<P>
+This server application builds and executes succesfully waiting for
+client requests to arrive.
+<P>
+</UL>
+FYI (from Doug):
+<UL>
+The ACCEPT_MASK is defined in the ACE_Event_Handler class. It's used
+to inform the Reactor that you want to register an event handler to
+"accept" a connection passively. Not surprisingly, the ACE_Acceptor
+component uses this.
+<P>
+The READ_MASK is also defined in the ACE_Event_Handler class. It's
+used to inform the Reactor that you want to register an event handler
+to "read" data from an established connection.
+</UL>
+<hr>
+SHAR_EOF
+ $shar_touch -am 0117140999 'page02.pre' &&
+ chmod 0664 'page02.pre' ||
+ $echo 'restore of' 'page02.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page02.pre:' 'MD5 check failed'
+5e23294cf842366a9ca1b14867856359 page02.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pre'`"
+ test 2188 -eq "$shar_count" ||
+ $echo 'page02.pre:' 'original size' '2188,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page03.pre ==============
+if test -f 'page03.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page03.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page03.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page03.pre' &&
+<P>Now we begin to look at the <A HREF="acceptor.h">acceptor</A> object.
+X
+<P>
+Kirthika has this analogy:
+<P>
+<UL>
+Consider an office:
+<P>
+Reactor: Receptionist
+<P>
+Event_Handlers: various Departments catering to specific needs.
+<P>
+SERVER_PORT: door
+<P>
+Acceptor: Doorkeeper
+<P>
+Thus when a needy person (client) enters the open door (port)
+maintained by the doorkeeper (acceptor waiting for connection
+request), the receptionist(reactor) directs the person towards the
+appropriate section (event_handler) which would cater to his needs.
+</UL>
+<P>
+<HR>
+SHAR_EOF
+ $shar_touch -am 0117140999 'page03.pre' &&
+ chmod 0664 'page03.pre' ||
+ $echo 'restore of' 'page03.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page03.pre:' 'MD5 check failed'
+b1eca88136f15c2c1156a2602daaff7e page03.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pre'`"
+ test 553 -eq "$shar_count" ||
+ $echo 'page03.pre:' 'original size' '553,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page04.pre ==============
+if test -f 'page04.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page04.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page04.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page04.pre' &&
+<P>Now we begin to look at the <A HREF="logger.h">logger</A>
+object.
+X
+<P>
+<HR>
+SHAR_EOF
+ $shar_touch -am 0117140999 'page04.pre' &&
+ chmod 0664 'page04.pre' ||
+ $echo 'restore of' 'page04.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page04.pre:' 'MD5 check failed'
+ea4861a868e3dce3607602f1ce35b7fa page04.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pre'`"
+ test 79 -eq "$shar_count" ||
+ $echo 'page04.pre:' 'original size' '79,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page05.pre ==============
+if test -f 'page05.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page05.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page05.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page05.pre' &&
+<P>This concludes the first tutorial on using ACE. We've learned how to
+create a simple server without knowing very much about network programming.
+X
+<P>The code used in this tutorial is for illustration purposes. That means
+it may or may not work.&nbsp;&nbsp; Actually, it <I>does</I> work but the
+astute reader will notice a number of places for potential memory leaks.&nbsp;
+We'll work on cleaning those up in future tutorials but if you find one
+feel free to send me a fix and I'll integrate it into the tutorial.
+X
+<UL>
+<LI>
+<A HREF="00SetEnv">Environment
+Settings</A></LI>
+X
+<LI>
+<A HREF="Makefile">Makefile</A></LI>
+X
+<LI>
+<A HREF="server.cpp">main
+program</A></LI>
+X
+<LI>
+<A HREF="acceptor.h">acceptor
+object</A></LI>
+X
+<LI>
+<A HREF="logger.h">connection
+handler</A></LI>
+</UL>
+X
+<P>
+To read more about the patterns used in this example (as well as
+quite a few which aren't!), you should check out
+<A HREF="http://www.cs.wustl.edu/~schmidt/patterns-ace.html">http://www.cs.wustl.edu/~schmidt/patterns-ace.html.</A>
+In fact, it's probably safe to say that the concepts found there will keep
+coming back to haunt you as these tutorials continue.
+<P>
+SHAR_EOF
+ $shar_touch -am 0117141399 'page05.pre' &&
+ chmod 0664 'page05.pre' ||
+ $echo 'restore of' 'page05.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page05.pre:' 'MD5 check failed'
+7d00b8c59c4f7210634bc5fdb75dfbcc page05.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page05.pre'`"
+ test 1149 -eq "$shar_count" ||
+ $echo 'page05.pre:' 'original size' '1149,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page02.pst ==============
+if test -f 'page02.pst' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page02.pst' '(file already exists)'
+else
+ $echo 'x -' extracting 'page02.pst' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page02.pst' &&
+<HR WIDTH="100%">
+X
+<P>As I said, the main program is really quite simple:
+<UL>
+<LI>
+Create an address for the <I>port</I> we want to listen to</LI>
+X
+<LI>
+Create an acceptor which listens on that address</LI>
+X
+<LI>
+Register the acceptor with a reactor to respond to the connection requests</LI>
+X
+<LI>
+Enter an infinite loop to let the reactor handle the events</LI>
+</UL>
+On the next page, we will take a look at the acceptor and how it responds
+to new connection requests.
+X
+<P>
+SHAR_EOF
+ $shar_touch -am 0117141299 'page02.pst' &&
+ chmod 0664 'page02.pst' ||
+ $echo 'restore of' 'page02.pst' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page02.pst:' 'MD5 check failed'
+51b1f08eabda5789182b566fdb7756fe page02.pst
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pst'`"
+ test 478 -eq "$shar_count" ||
+ $echo 'page02.pst:' 'original size' '478,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page03.pst ==============
+if test -f 'page03.pst' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page03.pst' '(file already exists)'
+else
+ $echo 'x -' extracting 'page03.pst' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page03.pst' &&
+<HR WIDTH="100%"></PRE>
+It is important to notice here that we have done very little application-specifc
+code in developing this object. In fact, if we take out the progress information,
+the only app-specific code is when we create the new <I>Logging_Handler</I>
+object to give to the <I>accept</I> function. You may begin to wonder why
+there isn't a C++ template that does all of this coding for you. Actually,
+the ACE toolkit happens to have one handy:
+<UL>typedef ACE_Acceptor &lt;<I>YourHandlerClass</I>, ACE_SOCK_ACCEPTOR>
+<I>YourAcceptorClass</I>;</UL>
+We would have used it like this:
+<UL>typedef ACE_Acceptor &lt;Logging_Handler, ACE_SOCK_ACCEPTOR> Client_Acceptor;</UL>
+This will create a piece of code similar to what I've shown above. The
+primary difference is that the <I>handle_input </I>function created by
+the template does NOT register the handler with the reactor. In the long-run,
+that is good for us because we can then move that logic into the <I>open</I>
+function of the <I>Logging_Handler</I> and use a completely-generic acceptor.
+X
+<P>Now that we know how to accept a connection request, let's move on to
+the next page where we learn how to handle the actual connection. Even
+though we just learned about this cool template thing, we will continue
+to use the "hand-written" acceptor developed above. As I mentioned, the
+only difference will be in the <I>open</I> function of the connection handler
+anyway.
+X
+<P>
+SHAR_EOF
+ $shar_touch -am 0117141299 'page03.pst' &&
+ chmod 0664 'page03.pst' ||
+ $echo 'restore of' 'page03.pst' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page03.pst:' 'MD5 check failed'
+7a18def18c6a83a1015e08f63b5868be page03.pst
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pst'`"
+ test 1434 -eq "$shar_count" ||
+ $echo 'page03.pst:' 'original size' '1434,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page04.pst ==============
+if test -f 'page04.pst' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page04.pst' '(file already exists)'
+else
+ $echo 'x -' extracting 'page04.pst' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page04.pst' &&
+<HR WIDTH="100%">
+X
+<P>
+The comments really should tell the story. The really
+interesting stuff is in <i>handle_input()</i>. Everything
+else is just housekeeping.
+In the future, we'll learn about ACE_Svc_Handler&lt;>
+which will take care of most of the housekeeping for us.
+<P>
+SHAR_EOF
+ $shar_touch -am 0117141299 'page04.pst' &&
+ chmod 0664 'page04.pst' ||
+ $echo 'restore of' 'page04.pst' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page04.pst:' 'MD5 check failed'
+5baa295de79c6c978bae3e496e32854e page04.pst
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pst'`"
+ test 279 -eq "$shar_count" ||
+ $echo 'page04.pst:' 'original size' '279,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh00080
+exit 0
diff --git a/docs/tutorials/001/page01.html b/docs/tutorials/001/page01.html
index 7dec4281754..3155a0b9c18 100644
--- a/docs/tutorials/001/page01.html
+++ b/docs/tutorials/001/page01.html
@@ -12,9 +12,7 @@
<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
-<P>
-<HR WIDTH="100%"></P>
-
+<hr>
<P>The purpose of this tutorial is to show you how to create a very simple
server capable of handling multiple client connections. Unlike a &quot;traditional&quot;
server application, this one handles all requests in one process. Issues
@@ -100,10 +98,5 @@ learn, don't worry. We'll go into all the details and explain as we go.
I only went into all of this so that it can kick around in the back of your
mind until you need it later.
<P>
-<HR WIDTH="100%"></P>
-
-<CENTER><P>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue
-This Tutorial</A>] </P></CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/001/page02.html b/docs/tutorials/001/page02.html
index ab303e46e56..dff82baa375 100644
--- a/docs/tutorials/001/page02.html
+++ b/docs/tutorials/001/page02.html
@@ -1,21 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+ <TITLE>ACE Tutorial 001</TITLE>
+ <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
<META NAME="Author" CONTENT="James CE Johnson">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
- <TITLE>ACE Tutorial 001</TITLE>
</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 001</FONT></B></CENTER>
-<CENTER><B><FONT SIZE=+2>A Beginners Guide to Using the ACE Toolkit</FONT></B></CENTER>
-
-
-<P>
-<HR WIDTH="100%">
+<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
+A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
+<hr>
<P>From here, we to move on to the main program loop. In a way, we're
starting at the final product when we do this, but it is a very simple
piece of code and a good place to start.
@@ -69,88 +66,94 @@ The READ_MASK is also defined in the ACE_Event_Handler class. It's
used to inform the Reactor that you want to register an event handler
to "read" data from an established connection.
</UL>
-<HR WIDTH="100%">
-<PRE>/*
-&nbsp; Include the header file where our client acceptor is defined.
-&nbsp;*/
-#include "ace/Reactor.h"
-
-/*&nbsp;&nbsp;
-&nbsp; For simplicity, we create our reactor in the global address space.
-&nbsp; In later tutorials we will do something more clever and appropriate. However,
-&nbsp; the purpose of this tutorial is to introduce a connection acceptance and
-&nbsp; handling, not the full capabilities of a reactor.
-*/
+<hr>
+<PRE>
+
+<font color=red>// $Id$</font>
+
+
+<font color=red>/*
+ Include the header file where our client acceptor is defined.
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/Reactor.h</font>"
+
+<font color=red>/*
+ For simplicity, we create our reactor in the global address space.
+ In later tutorials we will do something more clever and appropriate. However,
+ the purpose of this tutorial is to introduce a connection acceptance and
+ handling, not the full capabilities of a reactor.
+*/</font>
ACE_Reactor * g_reactor;
-/*
-&nbsp; Include the header where we define our acceptor object.&nbsp; An acceptor is
-&nbsp; an abstraction that allows a server to "accept" connections from clients.
-*/
-#include "acceptor.h"
-
-/*
-&nbsp; A TCP/IP server can listen to only one port for connection requests.
-&nbsp; Well-known services can always be found at the same address. Lesser-known
-&nbsp; services are generally told where to listen by a configuration file or
-&nbsp; command-line parameter. For this example, we're satisfied with simply hard-coding
-&nbsp; a random but known value.
-*/
+<font color=red>/*
+ Include the header where we define our acceptor object. An acceptor is
+ an abstraction that allows a server to "<font color=green>accept</font>" connections from clients.
+*/</font>
+<font color=blue>#include</font> "<font color=green>acceptor.h</font>"
+
+<font color=red>/*
+ A TCP/IP server can listen to only one port for connection requests.
+ Well-known services can always be found at the same address. Lesser-known
+ services are generally told where to listen by a configuration file or
+ command-line parameter. For this example, we're satisfied with simply hard-coding
+ a random but known value.
+*/</font>
static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
-int main (int, char **)
+int main (int, char *[])
{
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; Create a Reactor instance.&nbsp; Again, a global pointer isn't exactly the
-&nbsp;&nbsp;&nbsp; best way to handle this but for the simple example here, it will be OK.
-&nbsp;&nbsp;&nbsp; We'll get cute with it later.
-&nbsp; */
-&nbsp; g_reactor = new ACE_Reactor;
-
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; Like the Reactor, I'm skimming over the details of the ADDR
-&nbsp;&nbsp;&nbsp; object. What it provides is an abstraction for addressing services in the
-&nbsp;&nbsp;&nbsp; network. All we need to know at this point is that we are creating an address
-&nbsp;&nbsp;&nbsp; object which specifies the TCP/IP port on which the server
-&nbsp;&nbsp;&nbsp; will listen for new connection requests.
-&nbsp; */
-&nbsp; ACE_INET_Addr addr (PORT);
-
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; We now create an acceptor object.&nbsp; No connections will
-&nbsp;&nbsp;&nbsp; yet be established because the object isn't "open for business"
-&nbsp;&nbsp;&nbsp; at this time. Which brings us to the next line...
-&nbsp; */
-&nbsp; Logging_Acceptor * peer_acceptor = new Logging_Acceptor();
-
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; where the acceptor object is opened.&nbsp; You'll find that most ACE
-&nbsp;&nbsp;&nbsp; objects have to be open()ed before they're of any use to you.
-&nbsp;&nbsp;&nbsp; On this open() call, we're telling the acceptor where to listen
-&nbsp;&nbsp;&nbsp; for connections via the 'addr' object.&nbsp; We're also telling it
-&nbsp;&nbsp;&nbsp; that we want it to be registered with our 'g_reactor' instance.
-&nbsp;&nbsp; */
-&nbsp; if (peer_acceptor->open(addr,g_reactor) == -1 )
-&nbsp;&nbsp;&nbsp; ACE_ERROR_RETURN ((LM_ERROR, "Opening Acceptor\n"), -1);
-
-&nbsp; ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n"));
-
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; The reactor's handle_events member function is responsible for looking at
-&nbsp;&nbsp;&nbsp; all registered objects and invoking an appropriate member function when
-&nbsp;&nbsp;&nbsp; anything of interest occurs. When an event is processed, the handle_events
-&nbsp;&nbsp;&nbsp; function returns. In order to get all events, we embed this in an infinite
-&nbsp;&nbsp;&nbsp; loop.
-
-&nbsp;&nbsp;&nbsp; Since we put ourselves into an infinite loop, you'll need to CTRL-C
-&nbsp;&nbsp;&nbsp; to exit the program.
-&nbsp; */
-&nbsp; while (1)
-&nbsp;&nbsp;&nbsp;&nbsp; g_reactor-> handle_events ();
-
-&nbsp; return 0;
-}</PRE>
-
+ <font color=red>/*
+ Create a Reactor instance. Again, a global pointer isn't exactly the
+ best way to handle this but for the simple example here, it will be OK.
+ We'll get cute with it later.
+ */</font>
+ g_reactor = new ACE_Reactor;
+
+ <font color=red>/*
+ Like the Reactor, I'm skimming over the details of the ADDR
+ object. What it provides is an abstraction for addressing services in the
+ network. All we need to know at this point is that we are creating an address
+ object which specifies the TCP/IP port on which the server
+ will listen for new connection requests.
+ */</font>
+ ACE_INET_Addr addr (PORT);
+
+ <font color=red>/*
+ We now create an acceptor object. No connections will
+ yet be established because the object isn't "<font color=green>open for business</font>"
+ at this time. Which brings us to the next line...
+ */</font>
+ Logging_Acceptor * peer_acceptor = new Logging_Acceptor();
+
+ <font color=red>/*
+ where the acceptor object is opened. You'll find that most ACE
+ objects have to be open()ed before they're of any use to you.
+ On this open() call, we're telling the acceptor where to listen
+ for connections via the 'addr' object. We're also telling it
+ that we want it to be registered with our 'g_reactor' instance.
+ */</font>
+ if (peer_acceptor->open(addr,g_reactor) == -1 )
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>Opening Acceptor\n</font>"), -1);
+
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) starting up server logging daemon\n</font>"));
+
+ <font color=red>/*
+ The reactor's handle_events member function is responsible for looking at
+ all registered objects and invoking an appropriate member function when
+ anything of interest occurs. When an event is processed, the handle_events
+ function returns. In order to get all events, we embed this in an infinite
+ loop.
+
+ Since we put ourselves into an infinite loop, you'll need to CTRL-C
+ to exit the program.
+ */</font>
+ while (1)
+ g_reactor-> handle_events ();
+
+ return 0;
+}
+
+</PRE>
<HR WIDTH="100%">
<P>As I said, the main program is really quite simple:
@@ -171,11 +174,5 @@ On the next page, we will take a look at the acceptor and how it responds
to new connection requests.
<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page01.html">Previous
-Page</A>] [<A HREF="page03.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page03.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/001/page03.html b/docs/tutorials/001/page03.html
index 1b838d61bbd..5f45ca0826f 100644
--- a/docs/tutorials/001/page03.html
+++ b/docs/tutorials/001/page03.html
@@ -1,20 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+ <TITLE>ACE Tutorial 001</TITLE>
+ <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
<META NAME="Author" CONTENT="James CE Johnson">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
- <TITLE>ACE Tutorial 001</TITLE>
</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 001</FONT></B></CENTER>
-<CENTER><B><FONT SIZE=+2>A Beginners Guide to Using the ACE Toolkit</FONT></B></CENTER>
-
-<P>
-<HR WIDTH="100%">
+<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
+A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
+<hr>
<P>Now we begin to look at the <A HREF="acceptor.h">acceptor</A> object.
<P>
@@ -37,149 +35,157 @@ request), the receptionist(reactor) directs the person towards the
appropriate section (event_handler) which would cater to his needs.
</UL>
<P>
-<HR WIDTH="100%">
+<HR>
<PRE>
-#if !defined (_CLIENT_ACCEPTOR_H)
-#define _CLIENT_ACCEPTOR_H
-/*
+<font color=red>// $Id$</font>
+
+
+<font color=blue>#ifndef</font> <font color=purple>_CLIENT_ACCEPTOR_H</font>
+<font color=blue>#define</font> <font color=purple>_CLIENT_ACCEPTOR_H</font>
+
+<font color=red>/*
A SOCK_Acceptor knows how to accept socket connections. We'll use
one of those at the heart of our Logging_Acceptor.
- */
-#include "ace/SOCK_Acceptor.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Acceptor.h</font>"
+
+<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
+# pragma once
+<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-/*
+<font color=red>/*
An Event_Handler is what you register with ACE_Reactor. When events occur,
the reactor will callback on the Event_Handler. More on that in a few lines.
- */
-#include "ace/Event_Handler.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/Event_Handler.h</font>"
-/*
+<font color=red>/*
When a client connects, we'll create a Logging_Handler to deal with the
connection. Here, we bring in that declaration.
- */
-#include "logger.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>logger.h</font>"
-/*
+<font color=red>/*
Our Logging_Acceptor is derived from ACE_Event_Handler. That lets the
reactor treat our acceptor just like every other handler.
- */
+ */</font>
class Logging_Acceptor : public ACE_Event_Handler
{
public:
- /*
+ <font color=red>/*
For this simple case we won't bother with either constructor or
destructor. In a real application you would certainly have them.
- */
+ */</font>
- /*
+ <font color=red>/*
Here's the open() method we called from main(). We have two things
to accomplish here: (1) Open the acceptor so that we can hear
client requests and (2) register ourselves with the reactor so that
we can respond to those requests.
- */
- int open (const ACE_INET_Addr &amp;_addr, ACE_Reactor * _reactor )
+ */</font>
+ int open (const ACE_INET_Addr &_addr, ACE_Reactor * _reactor )
{
- /*
+ <font color=red>/*
Perform the open() on the acceptor. We pass through the address
at which main() wants us to listen. The second parameter tells
the acceptor it is OK to reuse the address. This is necessary
sometimes to get around closed connections that haven't timed out.
- */
- if (this->peer_acceptor_.open (_addr, 1) == -1)
- return -1;
+ */</font>
+ if (this->peer_acceptor_.open (_addr, 1) == -1)
+ return -1;
- /*
+ <font color=red>/*
Remember the reactor we're using. We'll need it later when we
create a client connection handler.
- */
+ */</font>
reactor_ = _reactor;
- /*
+ <font color=red>/*
Now we can register with the reactor we were given. Since the reactor
pointer is global, we could have just used that but it's gross enough
already.
Notice that we can pass 'this' right into the registration since we're
derived from ACE_Event_Handler. We also provide ACCEPT_MASK to tell
the reactor that we want to know about accept requests from clients.
- */
- return _reactor->register_handler( this, ACE_Event_Handler::ACCEPT_MASK );
+ */</font>
+ return _reactor->register_handler( this, <font color=#008888>ACE_Event_Handler::ACCEPT_MASK</font> );
}
-
+
private:
- /*
- To provide multi-OS abstraction, ACE uses the concept of "handles" for
+ <font color=red>/*
+ To provide multi-OS abstraction, ACE uses the concept of "<font color=green>handles</font>" for
connection endpoints. In Unix, this is a traditional file descriptor
(or integer). On other OS's, it may be something else.
The reactor will need to get the handle (file descriptor) to satisfy
it's own internal needs. Our relevant handle is the handle of the
acceptor object, so that's what we provide.
- */
+ */</font>
ACE_HANDLE get_handle (void) const
- {
- return this->peer_acceptor_.get_handle ();
+ {
+ return this->peer_acceptor_.get_handle ();
}
- /*
+ <font color=red>/*
When an accept request arrives, the reactor will invoke the handle_input()
callback. This is where we deal with the connection request.
- */
+ */</font>
virtual int handle_input (ACE_HANDLE _handle)
{
- /*
+ <font color=red>/*
The handle provided to us by the reactor is the one that triggered
our up-call. In some advanced situations, you might actually
register a single handler for multiple connections. The _handle
parameter is a way to sort 'em out. Since we don't use that
here, we simply ignore the parameter with the ACE_UNUSED_ARG() macro.
- */
+ */</font>
ACE_UNUSED_ARG(_handle);
- /*
+ <font color=red>/*
In response to the connection request, we create a new Logging_Handler.
This new object will be used to interact with the client until it
disconnects.
- */
+ */</font>
Logging_Handler *svc_handler = new Logging_Handler;
-
- /*
+
+ <font color=red>/*
To complete the connection, we invoke the accept() method call on
the acceptor object and provide it with the connection handler instance.
- This transfers "ownership" of the connection from the acceptor to the
+ This transfers "<font color=green>ownership</font>" of the connection from the acceptor to the
connection handler.
- */
+ */</font>
if (this->peer_acceptor_.accept (*svc_handler) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p", "accept failed"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p</font>", "<font color=green>accept failed</font>"), -1);
- /*
+ <font color=red>/*
Again, most objects need to be open()ed before they are useful. We'll
give the handler our reactor pointer so that it can register for
events as well. If the open fails, we'll force a close().
- */
+ */</font>
if (svc_handler->open (reactor_) == -1)
svc_handler->close ();
-
+
return 0;
}
protected:
- /*
+ <font color=red>/*
Our acceptor object instance
- */
- ACE_SOCK_Acceptor peer_acceptor_;
+ */</font>
+ ACE_SOCK_Acceptor peer_acceptor_;
- /*
+ <font color=red>/*
A place to remember our reactor pointer
- */
+ */</font>
ACE_Reactor * reactor_;
};
-#endif /* _CLIENT_ACCEPTOR_H */
-
+<font color=blue>#endif</font> <font color=red>/* _CLIENT_ACCEPTOR_H */</font>
+</PRE>
<HR WIDTH="100%"></PRE>
It is important to notice here that we have done very little application-specifc
code in developing this object. In fact, if we take out the progress information,
@@ -205,13 +211,5 @@ only difference will be in the <I>open</I> function of the connection handler
anyway.
<P>
-<HR WIDTH="100%">
-<CENTER></CENTER>
-
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page02.html">Previous
-Page</A>] [<A HREF="page04.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page04.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/001/page04.html b/docs/tutorials/001/page04.html
index be4742ae2ce..079947a3b3a 100644
--- a/docs/tutorials/001/page04.html
+++ b/docs/tutorials/001/page04.html
@@ -1,120 +1,124 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+ <TITLE>ACE Tutorial 001</TITLE>
+ <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
<META NAME="Author" CONTENT="James CE Johnson">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
- <TITLE>ACE Tutorial 001</TITLE>
</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 001</FONT></B></CENTER>
+<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
-<CENTER><B><FONT SIZE=+2>A Beginners Guide to Using the ACE Toolkit</FONT></B></CENTER>
+<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
+A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
-<P>
-<HR WIDTH="100%">
-
+<hr>
<P>Now we begin to look at the <A HREF="logger.h">logger</A>
object.
<P>
-<HR WIDTH="100%">
+<HR>
<PRE>
-#if !defined (_CLIENT_HANDLER_H)
-#define _CLIENT_HANDLER_H
-/*
+<font color=red>// $Id$</font>
+
+
+<font color=blue>#ifndef</font> <font color=purple>_CLIENT_HANDLER_H</font>
+<font color=blue>#define</font> <font color=purple>_CLIENT_HANDLER_H</font>
+
+<font color=red>/*
A connection handler will also be derived from ACE_Event_Handler so that we
can register with a reactor.
- */
-#include "ace/Event_Handler.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/Event_Handler.h</font>"
-#include "ace/INET_Addr.h"
+<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
+# pragma once
+<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-/*
+<font color=blue>#include</font> "<font color=green>ace/INET_Addr.h</font>"
+
+<font color=red>/*
Since we're doing TCP/IP, we'll need a SOCK_Stream for the connection.
- */
-#include "ace/SOCK_Stream.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Stream.h</font>"
class Logging_Handler : public ACE_Event_Handler
{
public:
- /*
+ <font color=red>/*
Like the acceptor, we're simple enough to avoid constructor and destructor.
- */
+ */</font>
- /*
+ <font color=red>/*
To open the client handler, we have to register ourselves with the reactor.
- Notice that we don't have to "open" our ACE_SOCK_Stream member variable.
+ Notice that we don't have to "<font color=green>open</font>" our ACE_SOCK_Stream member variable.
Why? Because the call to the acceptor's accept() method took care of those
details for us.
- */
+ */</font>
int open ( ACE_Reactor * _reactor )
{
- /*
+ <font color=red>/*
Remember our reactor...
- */
+ */</font>
reactor_ = _reactor;
- /*
+ <font color=red>/*
In this case we're using the READ_MASK. Like the acceptor, handle_input()
will be called due to this mask but it's a nice piece of bookkeeping to
have separate masks for the separate types of activity.
- */
- if (_reactor-> register_handler (this, ACE_Event_Handler::READ_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1);
-
+ */</font>
+ if (_reactor-> register_handler (this, <font color=#008888>ACE_Event_Handler::READ_MASK</font>) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) can't register with reactor\n</font>"), -1);
return 0;
}
- /*
- If we're explicitly closed we'll close our "file handle". The net result
+ <font color=red>/*
+ If we're explicitly closed we'll close our "<font color=green>file handle</font>". The net result
is to close the connection to the client and remove ourselves from the
reactor if we're registered
- */
+ */</font>
int close (void)
{
- return this->handle_close (ACE_INVALID_HANDLE, ACE_Event_Handler::RWE_MASK);
+ return this->handle_close (ACE_INVALID_HANDLE, <font color=#008888>ACE_Event_Handler::RWE_MASK</font>);
}
- /*
+ <font color=red>/*
This is a bit of magic... When we call the accept() method of the acceptor
object, it wants to do work on an ACE_SOCK_Stream. We have one of those as
our connection to the client but it would be gross to provide a method to
access that object. It's much cooler if the acceptor can just treat the
Logging_Handler as an ACE_SOCK_Stream. Providing this cast operator lets
that happen cleanly.
- */
- operator ACE_SOCK_Stream &amp;()
+ */</font>
+ operator ACE_SOCK_Stream &()
{
return this->cli_stream_;
}
protected:
- /*
+ <font color=red>/*
Again, like the acceptor, we need to provide the connection handle to the reactor.
- */
+ */</font>
ACE_HANDLE get_handle (void) const
{
return this->cli_stream_.get_handle ();
}
- /*
+ <font color=red>/*
And here's the handle_input(). This is really the workhorse of the application.
- */
+ */</font>
virtual int handle_input (ACE_HANDLE)
{
- /*
+ <font color=red>/*
Create and initialize a small receive buffer.
- */
+ */</font>
char buf[128];
memset(buf,0,sizeof(buf));
-
- /*
+
+ <font color=red>/*
Invoke the recv() method of the ACE_SOCK_Stream to get some data. It will
return -1 if there is an error. Otherwise, it will return the number of bytes
read. Of course, if it read zero bytes then the connection must be gone.
@@ -133,67 +137,66 @@ protected:
data is ready, that would be redundant. On the other hand, if you use recv_n()
to read *exactly* a number of bytes then limiting the time you wait for those
bytes might be good.
- The other paramter that may come in handy is an integer <i>flags</i>. This is
+ The other paramter that may come in handy is an integer &lt;i>flags&lt;/i>. This is
passed directly to the underlying OS recv() call. See the man page recv(2)
and the header sys/socket.h for the gory details.
- */
+ */</font>
switch( this->cli_stream_.recv(buf,sizeof buf) )
{
case -1:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p bad read\n", "client logger"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) %p bad read\n</font>", "<font color=green>client logger</font>"), -1);
case 0:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon (fd = %d)\n",
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) closing log daemon (fd = %d)\n</font>",
this->get_handle ()), -1);
default:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) from client: %s",buf));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) from client: %s</font>",buf));
}
-
+
return 0;
}
- /*
+ <font color=red>/*
When handle_input() returns -1, we'll end up here. There are a few housekeeping
chores to handle.
- */
+ */</font>
int handle_close (ACE_HANDLE, ACE_Reactor_Mask _mask)
{
- /*
+ <font color=red>/*
Remove ourselves from the reactor. We have to include the DONT_CALL in the
mask so that it won't call handle_close() on us again!
- */
- reactor_->remove_handler(this,_mask|ACE_Event_Handler::DONT_CALL);
+ */</font>
+ reactor_->remove_handler(this,_mask|<font color=#008888>ACE_Event_Handler::DONT_CALL</font>);
- /*
+ <font color=red>/*
Close the socket that we're connected to the client with.
- */
+ */</font>
cli_stream_.close();
- /*
+ <font color=red>/*
Since we know we were dynamically allocated by the acceptor, now is a good
time to get rid of ourselves.
- */
- delete this;
+ */</font>
+ delete this;
return 0;
}
protected:
- /*
+ <font color=red>/*
Our peer connection.
- */
- ACE_SOCK_Stream cli_stream_;
+ */</font>
+ ACE_SOCK_Stream cli_stream_;
- /*
+ <font color=red>/*
Our reactor (and our acceptor's reactor).
- */
+ */</font>
ACE_Reactor * reactor_;
};
-#endif /* _CLIENT_HANDLER_H */</PRE>
-
+<font color=blue>#endif</font> <font color=red>/* _CLIENT_HANDLER_H */</font>
-<P>
+</PRE>
<HR WIDTH="100%">
<P>
@@ -203,13 +206,5 @@ else is just housekeeping.
In the future, we'll learn about ACE_Svc_Handler&lt;>
which will take care of most of the housekeeping for us.
<P>
-<HR WIDTH="100%">
-<CENTER></CENTER>
-
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page03.html">Previous
-Page</A>] [<A HREF="page05.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page05.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/001/page05.html b/docs/tutorials/001/page05.html
index aa0fe927b00..8725e1f410f 100644
--- a/docs/tutorials/001/page05.html
+++ b/docs/tutorials/001/page05.html
@@ -1,21 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+ <TITLE>ACE Tutorial 001</TITLE>
+ <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
<META NAME="Author" CONTENT="James CE Johnson">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
- <TITLE>ACE Tutorial 001</TITLE>
</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 001</FONT></B></CENTER>
-<CENTER><B><FONT SIZE=+2>A Beginners Guide to Using the ACE Toolkit</FONT></B></CENTER>
-
-
-<P>
-<HR WIDTH="100%">
+<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 001<BR>
+A Beginners Guide to Using the ACE&nbsp;Toolkit</FONT></B></P></CENTER>
+<hr>
<P>This concludes the first tutorial on using ACE. We've learned how to
create a simple server without knowing very much about network programming.
@@ -53,12 +50,5 @@ quite a few which aren't!), you should check out
In fact, it's probably safe to say that the concepts found there will keep
coming back to haunt you as these tutorials continue.
<P>
-<HR WIDTH="100%">
-<CENTER></CENTER>
-
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page04.html">Previous
-Page</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/002/Makefile b/docs/tutorials/002/Makefile
index d590e57dac8..d5fd68fe510 100644
--- a/docs/tutorials/002/Makefile
+++ b/docs/tutorials/002/Makefile
@@ -29,6 +29,17 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
# Local targets
#----------------------------------------------------------------------------
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
diff --git a/docs/tutorials/002/combine.shar b/docs/tutorials/002/combine.shar
new file mode 100644
index 00000000000..498d2be4a46
--- /dev/null
+++ b/docs/tutorials/002/combine.shar
@@ -0,0 +1,328 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 1999-01-17 14:20 EST by <jcej@chiroptera.tragus.org>.
+# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/002'.
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 607 -rw-rw-r-- hdr
+# 28 -rw-rw-r-- bodies
+# 1027 -rw-rw-r-- page01.pre
+# 1819 -rw-rw-r-- page02.pre
+# 100 -rw-rw-r-- page03.pre
+# 448 -rw-rw-r-- page04.pre
+#
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+touch -am 1231235999 $$.touch >/dev/null 2>&1
+if test ! -f 1231235999 && test -f $$.touch; then
+ shar_touch=touch
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 1231235999 $$.touch
+#
+if mkdir _sh00205; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= hdr ==============
+if test -f 'hdr' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'hdr' '(file already exists)'
+else
+ $echo 'x -' extracting 'hdr' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
+<HTML>
+<HEAD>
+X <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+X <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+X <META NAME="Author" CONTENT="James CE Johnson">
+X <META NAME="Description" CONTENT="A first step towards using ACE productively">
+X <TITLE>ACE Tutorial 002</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+X
+<CENTER><B><FONT SIZE=+2>ACE Tutorial 002</FONT></B></CENTER>
+X
+<CENTER><B><FONT SIZE=+2>Creating a Better Server</FONT></B></CENTER>
+X
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117141599 'hdr' &&
+ chmod 0664 'hdr' ||
+ $echo 'restore of' 'hdr' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'hdr:' 'MD5 check failed'
+8a98117995f511d0ed9b699587b5b6a5 hdr
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
+ test 607 -eq "$shar_count" ||
+ $echo 'hdr:' 'original size' '607,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= bodies ==============
+if test -f 'bodies' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'bodies' '(file already exists)'
+else
+ $echo 'x -' extracting 'bodies' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
+PAGE=2
+server.cpp
+handler.h
+SHAR_EOF
+ $shar_touch -am 0117141899 'bodies' &&
+ chmod 0664 'bodies' ||
+ $echo 'restore of' 'bodies' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'bodies:' 'MD5 check failed'
+9ec2171f52b5b973c247ef550fb7b035 bodies
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
+ test 28 -eq "$shar_count" ||
+ $echo 'bodies:' 'original size' '28,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pre ==============
+if test -f 'page01.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
+X
+<P>In this tutorial, we will build a little on what we learned in the first
+tutorial and add a few extras. In the end, we will have a better server
+object that is actually simpler and more maintainable than the one we created
+before.</P>
+X
+<P>
+<HR WIDTH="100%"></P>
+X
+<P>To begin, let's ask ourselves the same thing we did at the beginning
+of tutorial 001:</P>
+X
+<UL>
+<P>What do you need to create a server?</P>
+</UL>
+X
+<OL>
+<OL>
+<LI>Something which accepts connections from clients</LI>
+X
+<LI>Something which handles established connections</LI>
+X
+<LI>A main program loop that handles it all</LI>
+</OL>
+</OL>
+X
+<P>Previously, we created a solution which addressed each one of these
+questions specifically. At the end of it all, we realized that our only
+application-specific coding was confined to the <I>handler</I> portion
+of the program. We hinted that there may be a way to eliminate hand-coding
+an <I>acceptor</I> each time we want to create a server. Here, we will
+explore that approach.</P>
+X
+SHAR_EOF
+ $shar_touch -am 0117141599 'page01.pre' &&
+ chmod 0664 'page01.pre' ||
+ $echo 'restore of' 'page01.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pre:' 'MD5 check failed'
+c5a9075793a200d7b2e49a092ee1ce6c page01.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
+ test 1027 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '1027,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page02.pre ==============
+if test -f 'page02.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page02.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page02.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page02.pre' &&
+X
+<P>Like Tutorial 1, this is also a rather small program.&nbsp; I'm going
+to add a couple of new ideas along the way but to make up for it I'm also
+going to simplify the acceptor a great deal.
+X
+<P>
+Kirthika's Abstract:
+<UL>
+This is a server example made simpler due to the use of off-the-shelf
+components and classes from ACE.
+<P>
+Here, the Logging_Acceptor is an ACE_Acceptor class which is associated
+with the Logging_Handler and the ACE_SOCK_ACCEPTOR. This will now
+accept connection requests from the clients on being opened with the
+reactor instance passed to it.
+<P>
+We also implement a signal to capture CTRL-C [ which generates SIGINT ] using ACE_SigAction and
+ACE_SignalHandler. This signal can now be used to stop the reactor
+from handling events.
+<P>
+Then, the reactor is allowed to loop infintely until it is shut down
+using a ^C, after which both the reactor as well as the acceptor are
+destroyed.
+<P>
+The Logging_Handler derives from the ACE_Svc_Handler instead of the
+Event_Handler since the Svc_Handler has inbuilt SOCK_Stream and
+provides all the calls needed by the reactor. The Svc_Handler has the
+ability to react to events and communicate to remote tasks using the
+underlying data stream passed to it.
+<P>
+A timer is scheduled in the reactor which does nothing but simply
+display how it could be used to provide periodic processing when
+needed. The ACE_TimeValue is used to set the time period.
+<P>
+Also, optimisations have been made in the form of a separate function
+for
+destroying the objects used.
+<P>
+Thus a simpler server has now been built which successfully
+demonstrates how simple a task, writing a server can become on using
+the various ACE components judiciously.
+</UL>
+<P>We begin by looking at the <A HREF="server.cpp">main (server.cpp)</A> portion program:
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117141899 'page02.pre' &&
+ chmod 0664 'page02.pre' ||
+ $echo 'restore of' 'page02.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page02.pre:' 'MD5 check failed'
+41fa9b0b5cced9b45407b397a57482ca page02.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pre'`"
+ test 1819 -eq "$shar_count" ||
+ $echo 'page02.pre:' 'original size' '1819,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page03.pre ==============
+if test -f 'page03.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page03.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page03.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page03.pre' &&
+X
+<P>Now lets take a look at the new <A HREF="handler.h">Logging_Handler</A>:
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117141899 'page03.pre' &&
+ chmod 0664 'page03.pre' ||
+ $echo 'restore of' 'page03.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page03.pre:' 'MD5 check failed'
+f62bcf39007ec332f581a0849e33fe50 page03.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pre'`"
+ test 100 -eq "$shar_count" ||
+ $echo 'page03.pre:' 'original size' '100,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page04.pre ==============
+if test -f 'page04.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page04.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page04.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page04.pre' &&
+X
+<P>Well, that's it for the second tutorial. We've found a much easier way
+to create a server, especially the acceptor part. At the same time, we
+introduced more functionality and robustness. Not bad for a day's work.
+<BR>&nbsp;
+<UL>
+<LI>
+<A HREF="00SetEnv">Environment
+Settings</A></LI>
+X
+<LI>
+<A HREF="Makefile">Makefile</A></LI>
+X
+<LI>
+<A HREF="server.cpp">server.cpp</A></LI>
+<LI>
+<A HREF="handler.h">handler.h</A></LI>
+</UL>
+X
+SHAR_EOF
+ $shar_touch -am 0117142099 'page04.pre' &&
+ chmod 0664 'page04.pre' ||
+ $echo 'restore of' 'page04.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page04.pre:' 'MD5 check failed'
+b9cf47308b8215298848b4819f6d447c page04.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pre'`"
+ test 448 -eq "$shar_count" ||
+ $echo 'page04.pre:' 'original size' '448,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh00205
+exit 0
diff --git a/docs/tutorials/002/page01.html b/docs/tutorials/002/page01.html
index 6b30588b567..280bb0de807 100644
--- a/docs/tutorials/002/page01.html
+++ b/docs/tutorials/002/page01.html
@@ -1,19 +1,20 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
- <TITLE>ACE Tutorial 002</TITLE>
- <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+ <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
<META NAME="Author" CONTENT="James CE Johnson">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
+ <TITLE>ACE Tutorial 002</TITLE>
</HEAD>
-<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+<CENTER><B><FONT SIZE=+2>ACE Tutorial 002</FONT></B></CENTER>
+
+<CENTER><B><FONT SIZE=+2>Creating a Better Server</FONT></B></CENTER>
-<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 002<BR>
-Creating a Better Server </FONT></B></P></CENTER>
<P>
-<HR WIDTH="100%"></P>
+<HR WIDTH="100%">
<P>In this tutorial, we will build a little on what we learned in the first
tutorial and add a few extras. In the end, we will have a better server
@@ -47,11 +48,5 @@ of the program. We hinted that there may be a way to eliminate hand-coding
an <I>acceptor</I> each time we want to create a server. Here, we will
explore that approach.</P>
-<P>
-<HR WIDTH="100%"></P>
-
-<CENTER><P>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue
-This Tutorial</A>] </P></CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/002/page02.html b/docs/tutorials/002/page02.html
index 2c167a2a5cd..eb1ab5893e2 100644
--- a/docs/tutorials/002/page02.html
+++ b/docs/tutorials/002/page02.html
@@ -62,101 +62,95 @@ the various ACE components judiciously.
<P>
<HR WIDTH="100%">
<PRE>
-/*
-&nbsp; As before, we need a few ACE objects as well as our Logging_Handler declaration.
-&nbsp;*/
-#include "ace/Acceptor.h"
-#include "ace/SOCK_Acceptor.h"
-#include "ace/Reactor.h"
-#include "handler.h"
-
-/*
-&nbsp; We'll still use the global reactor pointer.&nbsp; There's a snappy way around this
-&nbsp; that shows up in later server tutorials.
-&nbsp;*/
+
+<font color=red>// $Id$</font>
+
+
+<font color=red>/*
+ As before, we need a few ACE objects as well as our Logging_Handler declaration.
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/Acceptor.h</font>"
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Acceptor.h</font>"
+<font color=blue>#include</font> "<font color=green>ace/Reactor.h</font>"
+<font color=blue>#include</font> "<font color=green>handler.h</font>"
+
+<font color=red>/*
+ We'll still use the global reactor pointer. There's a snappy way around this
+ that shows up in later server tutorials.
+ */</font>
ACE_Reactor * g_reactor;
-/*
-&nbsp; This was hinted at in Tutorial 1.&nbsp; Remember the hand-coded acceptor that we
-&nbsp; created there?&nbsp; This template does all of that and more and better.&nbsp; If you
-&nbsp; find yourself creating code that doesn't feel like a part of your application,
-&nbsp; there's a good chance that ACE has a template or framework component to do
-&nbsp; it for you.
-&nbsp;*/
+<font color=red>/*
+ This was hinted at in Tutorial 1. Remember the hand-coded acceptor that we
+ created there? This template does all of that and more and better. If you
+ find yourself creating code that doesn't feel like a part of your application,
+ there's a good chance that ACE has a template or framework component to do
+ it for you.
+ */</font>
typedef ACE_Acceptor &lt; Logging_Handler, ACE_SOCK_ACCEPTOR > Logging_Acceptor;
-/*
-&nbsp; One of the new things will be a signal handler so that we can exit the application
-&nbsp; somewhat cleanly.&nbsp; The 'finished' flag is used instead of the previous infninite
-&nbsp; loop and the 'handler' will set that flag in respose to SIGINT (CTRL-C).
-&nbsp;*/
+<font color=red>/*
+ One of the new things will be a signal handler so that we can exit the application
+ somewhat cleanly. The 'finished' flag is used instead of the previous infninite
+ loop and the 'handler' will set that flag in respose to SIGINT (CTRL-C).
+ */</font>
static sig_atomic_t finished = 0;
-extern "C" void handler (int)
+extern "<font color=green>C</font>" void handler (int)
{
-&nbsp; finished = 1;
+ finished = 1;
}
static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
int main (int, char **)
{
-&nbsp; // Create the reactor we'll register our event handler derivatives with.
-&nbsp; g_reactor = new ACE_Reactor;
+ <font color=red>// Create the reactor we'll register our event handler derivatives with.</font>
+ g_reactor = new ACE_Reactor;
-&nbsp; // Create the acceptor that will listen for client connetions
-&nbsp; Logging_Acceptor peer_acceptor;
+ <font color=red>// Create the acceptor that will listen for client connetions</font>
+ Logging_Acceptor peer_acceptor;
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; Notice how similar this is to the open() call in Tutorial 1.&nbsp; I read
-&nbsp;&nbsp;&nbsp; ahead when I created that one so that it would come out this way...
-&nbsp;&nbsp; */
-&nbsp; if (peer_acceptor.open (ACE_INET_Addr (PORT), g_reactor) == -1)
-&nbsp;&nbsp;&nbsp; ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ <font color=red>/*
+ Notice how similar this is to the open() call in Tutorial 1. I read
+ ahead when I created that one so that it would come out this way...
+ */</font>
+ if (peer_acceptor.open (ACE_INET_Addr (PORT), g_reactor) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1);
-&nbsp; /*
-&nbsp;&nbsp;&nbsp; Here's the easiest way to respond to signals in your application.&nbsp; Simply
-&nbsp;&nbsp;&nbsp; construct an ACE_Sig_Action object with a "C" function and the signal you
-&nbsp;&nbsp;&nbsp; want to capture.&nbsp; As you might expect, there is also a way to register
-&nbsp;&nbsp;&nbsp; signal handlers with a reactor but we take the easy-out here.
-&nbsp;&nbsp; */
-&nbsp; ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
+ <font color=red>/*
+ Here's the easiest way to respond to signals in your application. Simply
+ construct an ACE_Sig_Action object with a "<font color=green>C</font>" function and the signal you
+ want to capture. As you might expect, there is also a way to register
+ signal handlers with a reactor but we take the easy-out here.
+ */</font>
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
-&nbsp; ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n"));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) starting up server logging daemon\n</font>"));
-&nbsp; // Perform logging service until the signal handler receives SIGINT.
-&nbsp; while (!finished)
-&nbsp;&nbsp;&nbsp; g_reactor->handle_events ();
+ <font color=red>// Perform logging service until the signal handler receives SIGINT.</font>
+ while (!finished)
+ g_reactor->handle_events ();
-&nbsp; // Close the acceptor so that no more clients will be taken in.
-&nbsp; peer_acceptor.close();
+ <font color=red>// Close the acceptor so that no more clients will be taken in.</font>
+ peer_acceptor.close();
-&nbsp; // Free up the memory allocated for the reactor.
-&nbsp; delete g_reactor;
+ <font color=red>// Free up the memory allocated for the reactor.</font>
+ delete g_reactor;
-&nbsp; ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n"));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) shutting down server logging daemon\n</font>"));
-&nbsp; return 0;
+ return 0;
}
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+<font color=blue>#if defined</font> (<font color=purple>ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION</font>)
template class ACE_Acceptor &lt;Logging_Handler, ACE_SOCK_ACCEPTOR>;
template class ACE_Svc_Handler&lt;ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Acceptor &lt;Logging_Handler, ACE_SOCK_ACCEPTOR>
-#pragma instantiate ACE_Svc_Handler&lt;ACE_SOCK_STREAM, ACE_NULL_SYNCH>
-#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
+<font color=blue>#elif defined</font> (<font color=purple>ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA</font>)
+<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Acceptor &lt;Logging_Handler, ACE_SOCK_ACCEPTOR>
+<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Svc_Handler&lt;ACE_SOCK_STREAM, ACE_NULL_SYNCH>
+<font color=blue>#endif</font> <font color=red>/* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */</font>
</PRE>
-
-
-<P>
-<HR WIDTH="100%">
-<CENTER></CENTER>
-
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page01.html">Previous
-Page</A>] [<A HREF="page03.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page03.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/002/page03.html b/docs/tutorials/002/page03.html
index 3082cc4dd08..f5af30830d0 100644
--- a/docs/tutorials/002/page03.html
+++ b/docs/tutorials/002/page03.html
@@ -20,122 +20,134 @@
<P>
<HR WIDTH="100%">
-<BR>
-<PRE>#ifndef LOGGING_HANDLER_H
-#define LOGGING_HANDLER_H
+<PRE>
-/*
+<font color=red>// $Id$</font>
+
+<font color=blue>#ifndef</font> <font color=purple>LOGGING_HANDLER_H</font>
+<font color=blue>#define</font> <font color=purple>LOGGING_HANDLER_H</font>
+
+<font color=blue>#include</font> "<font color=green>ace/INET_Addr.h</font>"
+
+<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
+# pragma once
+<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
+
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Stream.h</font>"
+<font color=blue>#include</font> "<font color=green>ace/Reactor.h</font>"
+
+<font color=red>/*
Since we used the template to create the acceptor, we don't know if there is a
way to get to the reactor it uses. We'll take the easy way out and grab the
global pointer. (There is a way to get back to the acceptor's reactor that
we'll see later on.)
- */
+ */</font>
extern ACE_Reactor * g_reactor;
-/*
+<font color=red>/*
This time we're deriving from ACE_Svc_Handler instead of ACE_Event_Handler.
The big reason for this is because it already knows how to contain a SOCK_Stream
and provides all of the method calls needed by the reactor. The second template
parameter is for some advanced stuff we'll do with later servers. For now, just
use it as is...
- */
+ */</font>
class Logging_Handler : public ACE_Svc_Handler &lt; ACE_SOCK_STREAM, ACE_NULL_SYNCH >
{
public:
- /*
+ <font color=red>/*
The Acceptor&lt;> template will open() us when there is a new client connection.
- */
- int open (void *)
+ */</font>
+ virtual int open (void *)
{
ACE_INET_Addr addr;
- /*
+ <font color=red>/*
Ask the peer() (held in our baseclass) to tell us the address of the cient
which has connected. There may be valid reasons for this to fail where we
wouldn't want to drop the connection but I can't think of one.
- */
+ */</font>
if (this->peer ().get_remote_addr (addr) == -1)
return -1;
- /*
+ <font color=red>/*
The Acceptor&lt;> won't register us with it's reactor, so we have to do so
ourselves. This is where we have to grab that global pointer. Notice
that we again use the READ_MASK so that handle_input() will be called
when the client does something.
- */
- if (g_reactor->register_handler (this, ACE_Event_Handler::READ_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1);
+ */</font>
+ if (g_reactor->register_handler (this, <font color=#008888>ACE_Event_Handler::READ_MASK</font>) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) can't register with reactor\n</font>"), -1);
- /*
+ <font color=red>/*
Here's another new treat. We schedule a timer event. This particular one
will fire in two seconds and then every three seconds after that. It doesn't
serve any useful purpose in our application other than to show you how it
is done.
- */
+ */</font>
else if (g_reactor->schedule_timer (this, 0, ACE_Time_Value (2), ACE_Time_Value (3)) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>can'(%P|%t) t register with reactor\n</font>"), -1);
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", addr.get_host_name() ));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) connected with %s\n</font>", addr.get_host_name() ));
return 0;
}
- /*
- This is a matter of style &amp; maybe taste. Instead of putting all of this stuff
+ <font color=red>/*
+ This is a matter of style & maybe taste. Instead of putting all of this stuff
into a destructor, we put it here and request that everyone call destroy()
instead of 'delete'.
- */
- void destroy (void)
+ */</font>
+ virtual void destroy (void)
{
- /*
+ <font color=red>/*
Remove ourselves from the reactor
- */
- g_reactor->remove_handler(this,ACE_Event_Handler::READ_MASK|ACE_Event_Handler::DONT_CALL);
+ */</font>
+ g_reactor->remove_handler(this,<font color=#008888>ACE_Event_Handler::READ_MASK</font>|ACE_Event_Handler::DONT_CALL);
- /*
+ <font color=red>/*
Cancel that timer we scheduled in open()
- */
+ */</font>
g_reactor->cancel_timer (this);
- /*
+ <font color=red>/*
Shut down the connection to the client.
- */
+ */</font>
this->peer ().close ();
- /*
+ <font color=red>/*
Free our memory.
- */
+ */</font>
delete this;
}
- /*
+ <font color=red>/*
If somebody doesn't like us, they will close() us. Actually, if our open() method
returns -1, the Acceptor&lt;> will invoke close() on us for cleanup.
- */
+ */</font>
virtual int close (u_long _flags = 0)
{
- /*
+ <font color=red>/*
The ACE_Svc_Handler baseclass requires the _flags parameter. We don't
use it here though, so we mark it as UNUSED. You can accomplish the
same thing with a signature like handle_input's below.
- */
- ACE_UNUSED_ARG(_flags);
+ */</font>
+ ACE_UNUSED_ARG(_flags);
- /*
+ <font color=red>/*
Clean up and go away.
- */
+ */</font>
this->destroy ();
return 0;
}
protected:
- /*
+ <font color=red>/*
Respond to input just like Tutorial 1.
- */
- int handle_input (ACE_HANDLE)
+ */</font>
+ virtual int handle_input (ACE_HANDLE)
{
char buf[128];
memset (buf, 0, sizeof (buf));
@@ -143,48 +155,38 @@ protected:
switch (this->peer ().recv (buf, sizeof buf))
{
case -1:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p bad read\n", "client logger"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) %p bad read\n</font>", "<font color=green>client logger</font>"), -1);
case 0:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon (fd = %d)\n", this->get_handle ()), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) closing log daemon (fd = %d)\n</font>", this->get_handle ()), -1);
default:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) from client: %s", buf));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) from client: %s</font>", buf));
}
return 0;
}
- /*
+ <font color=red>/*
When the timer expires, handle_timeout() will be called. The 'arg' is the value passed
after 'this' in the schedule_timer() call. You can pass in anything there that you can
cast to a void*.
- */
- int handle_timeout (const ACE_Time_Value &amp; tv, const void *arg)
+ */</font>
+ virtual int handle_timeout (const ACE_Time_Value & tv, const void *arg)
{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) handling timeout from this = %u\n</font>", this));
return 0;
}
- /*
+ <font color=red>/*
Clean ourselves up when handle_input() (or handle_timer()) returns -1
- */
- int handle_close(ACE_HANDLE, ACE_Reactor_Mask _mask)
+ */</font>
+ virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask _mask)
{
this->destroy();
return 0;
}
};
-#endif // LOGGING_HANDLER_H</PRE>
-
-
-<P>
-<HR WIDTH="100%">
-<CENTER></CENTER>
-
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page02.html">Previous
-Page</A>] [<A HREF="page04.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<font color=blue>#endif</font> <font color=red>// LOGGING_HANDLER_H</font>
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page04.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/002/page04.html b/docs/tutorials/002/page04.html
index 14837122aca..15a58015b48 100644
--- a/docs/tutorials/002/page04.html
+++ b/docs/tutorials/002/page04.html
@@ -30,12 +30,9 @@ Settings</A></LI>
<LI>
<A HREF="server.cpp">server.cpp</A></LI>
+<LI>
+<A HREF="handler.h">handler.h</A></LI>
</UL>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page03.html">Previous
-Page</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/003/Makefile b/docs/tutorials/003/Makefile
index c5da941f1b7..e75b4b8d7a7 100644
--- a/docs/tutorials/003/Makefile
+++ b/docs/tutorials/003/Makefile
@@ -30,7 +30,18 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
#----------------------------------------------------------------------------
# Local targets
#----------------------------------------------------------------------------
-
+
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre *.pst > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
diff --git a/docs/tutorials/003/client.cpp b/docs/tutorials/003/client.cpp
index 1e5ccf45f71..5156b5764a8 100644
--- a/docs/tutorials/003/client.cpp
+++ b/docs/tutorials/003/client.cpp
@@ -7,7 +7,7 @@
#include "ace/SOCK_Connector.h"
/*
- Unlike the previous two Tutorials, we're going to allow the user to provide
+ Unlike the previous two tutorials, we're going to allow the user to provide
command line options this time. Still, we need defaults in case that isn't
done.
*/
@@ -76,12 +76,12 @@ int main (int argc, char *argv[])
keep trying until all of the data is sent or simply give up. The send_n() function
already does the "keep trying" option for us, so we use it.
- Like the send() method used in the servers we've seen, there are two additional
- parameters you can use on the send() and send_n() method calls. The timeout
- parameter limits the amount of time the system will attempt to send the data
- to the peer. The flags parameter is passed directly to the OS send() system
- call. See send(2) for the valid flags values.
- */
+ Like the send() method used in the servers we've seen, there are two additional
+ parameters you can use on the send() and send_n() method calls. The timeout
+ parameter limits the amount of time the system will attempt to send the data
+ to the peer. The flags parameter is passed directly to the OS send() system
+ call. See send(2) for the valid flags values.
+ */
if (server.send_n ( buf, strlen(buf) ) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1);
diff --git a/docs/tutorials/003/combine.shar b/docs/tutorials/003/combine.shar
new file mode 100644
index 00000000000..7c5c12cd372
--- /dev/null
+++ b/docs/tutorials/003/combine.shar
@@ -0,0 +1,217 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 1999-01-17 14:27 EST by <jcej@chiroptera.tragus.org>.
+# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/003'.
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 607 -rw-rw-r-- hdr
+# 17 -rw-rw-r-- bodies
+# 1155 -rw-rw-r-- page01.pre
+# 447 -rw-rw-r-- page01.pst
+#
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+touch -am 1231235999 $$.touch >/dev/null 2>&1
+if test ! -f 1231235999 && test -f $$.touch; then
+ shar_touch=touch
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 1231235999 $$.touch
+#
+if mkdir _sh00333; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= hdr ==============
+if test -f 'hdr' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'hdr' '(file already exists)'
+else
+ $echo 'x -' extracting 'hdr' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
+<HTML>
+<HEAD>
+X <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+X <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+X <META NAME="Author" CONTENT="James CE Johnson">
+X <META NAME="Description" CONTENT="A first step towards using ACE productively">
+X <TITLE>ACE Tutorial 003</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+X
+<CENTER><B><FONT SIZE=+2>ACE Tutorial 003</FONT></B></CENTER>
+X
+<CENTER><B><FONT SIZE=+2>Creating a Simple Client</FONT></B></CENTER>
+X
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117142499 'hdr' &&
+ chmod 0664 'hdr' ||
+ $echo 'restore of' 'hdr' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'hdr:' 'MD5 check failed'
+91fd92d4f4daf6d2c38ccda9486b10ee hdr
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
+ test 607 -eq "$shar_count" ||
+ $echo 'hdr:' 'original size' '607,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= bodies ==============
+if test -f 'bodies' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'bodies' '(file already exists)'
+else
+ $echo 'x -' extracting 'bodies' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
+PAGE=1
+client.cpp
+SHAR_EOF
+ $shar_touch -am 0117142499 'bodies' &&
+ chmod 0664 'bodies' ||
+ $echo 'restore of' 'bodies' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'bodies:' 'MD5 check failed'
+773a1437ce449e55856a43c0538ca5b2 bodies
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
+ test 17 -eq "$shar_count" ||
+ $echo 'bodies:' 'original size' '17,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pre ==============
+if test -f 'page01.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
+X
+<P>Now that we've seen how to create servers, let's spend just a moment
+making a client. Since this is so easy, I'm going to do all of it in this
+one page.
+X
+<P>
+Kirthika says, "Here's an one paragraph abstract for a one page client app:"
+X
+<UL>
+X The server is an Stream object of ACE_SOCK_Stream type. The
+X ACE_Sock_Connector does the job of actively making a connection with the
+X listening server. It does so using the server_host_address and port
+X number which are stored in the ACE_INET_Addr object.Once the
+X connection has been established, the client begins its interaction
+X with the server and bombards it with messages.
+X Note: send_n() call is used since this call sees to the issues of
+X network buffering and reliably gets the data across to the server.
+X Also, a timeout value is set to provide fault tolerance if the server
+X ever dies before the transaction is completed. The server calls a
+X close() method
+X once it reads in zero bytes during the Event_Handler::handle_input()
+X call. This
+X proves that the client has severed its connection. The server then
+X shuts down.
+</UL>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117142499 'page01.pre' &&
+ chmod 0664 'page01.pre' ||
+ $echo 'restore of' 'page01.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pre:' 'MD5 check failed'
+c35cf15b292804d248dee8e4cc6feec5 page01.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
+ test 1155 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '1155,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pst ==============
+if test -f 'page01.pst' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pst' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pst' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pst' &&
+<HR WIDTH="100%">
+X
+<P>Ok, so that was pretty easy. What would be even easier would be to wrap
+all of the connection mess up in an object and overload a couple of basic
+operators to make things less network-centric. Perhaps we'll see that in
+another tutorial.
+X
+<P>If you want to compile it yourself, here's the <A HREF="client.cpp">source</A>,
+the <A HREF="Makefile">Makefile</A>,
+and <A HREF="00SetEnv">Environment
+settings</A>.
+X
+<P>
+SHAR_EOF
+ $shar_touch -am 0117142499 'page01.pst' &&
+ chmod 0664 'page01.pst' ||
+ $echo 'restore of' 'page01.pst' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pst:' 'MD5 check failed'
+9c3589ed1d86da267d589599f914141e page01.pst
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pst'`"
+ test 447 -eq "$shar_count" ||
+ $echo 'page01.pst:' 'original size' '447,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh00333
+exit 0
diff --git a/docs/tutorials/003/page01.html b/docs/tutorials/003/page01.html
index 0c371742d5c..d2d72870967 100644
--- a/docs/tutorials/003/page01.html
+++ b/docs/tutorials/003/page01.html
@@ -41,115 +41,119 @@ Kirthika says, "Here's an one paragraph abstract for a one page client app:"
shuts down.
</UL>
<HR WIDTH="100%">
-<PRE>/*
+<PRE>
+
+<font color=red>// $Id$</font>
+
+<font color=red>/*
To establish a socket connection to a server, we'll need an ACE_SOCK_Connector.
- */
-#include "ace/SOCK_Connector.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Connector.h</font>"
-/*
+<font color=red>/*
Unlike the previous two tutorials, we're going to allow the user to provide
command line options this time. Still, we need defaults in case that isn't
done.
- */
+ */</font>
static u_short SERVER_PORT = ACE_DEFAULT_SERVER_PORT;
static const char *const SERVER_HOST = ACE_DEFAULT_SERVER_HOST;
static const int MAX_ITERATIONS = 4;
int main (int argc, char *argv[])
{
- /*
+ <font color=red>/*
Accept the users's choice of hosts or use the default. Then do the same
for the TCP/IP port at which the server is listening as well as the
number of iterations to perform.
- */
+ */</font>
const char *server_host = argc > 1 ? argv[1] : SERVER_HOST;
- u_short server_port = argc > 2 ? ACE_OS::atoi (argv[2]) : SERVER_PORT;
- int max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : MAX_ITERATIONS;
+ u_short server_port = argc > 2 ? <font color=#008888>ACE_OS::atoi</font> (argv[2]) : SERVER_PORT;
+ int max_iterations = argc > 3 ? <font color=#008888>ACE_OS::atoi</font> (argv[3]) : MAX_ITERATIONS;
- /*
+ <font color=red>/*
Build ourselves a Stream socket. This is a connected socket that provides
reliable end-to-end communications. We will use the server object to send
data to the server we connect to.
- */
+ */</font>
ACE_SOCK_Stream server;
- /*
+ <font color=red>/*
And we need a connector object to establish that connection. The ACE_SOCK_Connector
object provides all of the tools we need to establish a connection once we know the
server's network address...
- */
+ */</font>
ACE_SOCK_Connector connector;
- /*
+ <font color=red>/*
Which we create with an ACE_INET_Addr object. This object is given the TCP/IP port
and hostname of the server we want to connect to.
- */
+ */</font>
ACE_INET_Addr addr (server_port, server_host);
- /*
+ <font color=red>/*
So, we feed the Addr object and the Stream object to the connector's connect() member
function. Given this information, it will establish the network connection to the
server and attach that connection to the server object.
- */
+ */</font>
if (connector.connect (server, addr) == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1);
}
- /*
+ <font color=red>/*
Just for grins, we'll send the server several messages.
- */
+ */</font>
for (int i = 0; i &lt; max_iterations; i++)
{
char buf[BUFSIZ];
- /*
+ <font color=red>/*
Create our message with the message number
- */
- ACE_OS::sprintf (buf, "message = %d\n", i + 1);
+ */</font>
+ <font color=#008888>ACE_OS::sprintf</font> (buf, "<font color=green>message = %d\n</font>", i + 1);
- /*
+ <font color=red>/*
Send the message to the server. We use the server object's send_n() function to
send all of the data at once. There is also a send() function but it may not send
all of the data. That is due to network buffer availability and such. If the send()
doesn't send all of the data, it is up to you to program things such that it will
keep trying until all of the data is sent or simply give up. The send_n() function
- already does the "keep trying" option for us, so we use it.
-
- Like the send() method used in the servers we've seen, there are two additional
- parameters you can use on the send() and send_n() method calls. The timeout
- parameter limits the amount of time the system will attempt to send the data
- to the peer. The flags parameter is passed directly to the OS send() system
- call. See send(2) for the valid flags values.
- */
+ already does the "<font color=green>keep trying</font>" option for us, so we use it.
+
+ Like the send() method used in the servers we've seen, there are two additional
+ parameters you can use on the send() and send_n() method calls. The timeout
+ parameter limits the amount of time the system will attempt to send the data
+ to the peer. The flags parameter is passed directly to the OS send() system
+ call. See send(2) for the valid flags values.
+ */</font>
if (server.send_n ( buf, strlen(buf) ) == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>send</font>"), -1);
}
else
{
- /*
+ <font color=red>/*
Pause for a second.
- */
- ACE_OS::sleep (1);
+ */</font>
+ <font color=#008888>ACE_OS::sleep</font> (1);
}
}
- /*
+ <font color=red>/*
Close the connection to the server. The servers we've created so far all are based
on the ACE_Reactor. When we close(), the server's reactor will see activity for
the registered event handler and invoke handle_input(). That, in turn, will try
to read from the socket but get back zero bytes. At that point, the server will know
that we've closed from our side.
- */
+ */</font>
if (server.close () == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>close</font>"), -1);
}
return 0;
-}</PRE>
-
+}
+</PRE>
<HR WIDTH="100%">
<P>Ok, so that was pretty easy. What would be even easier would be to wrap
@@ -163,9 +167,5 @@ and <A HREF="00SetEnv">Environment
settings</A>.
<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/004/Makefile b/docs/tutorials/004/Makefile
index 06940b7f6c4..0ab1d500aa7 100644
--- a/docs/tutorials/004/Makefile
+++ b/docs/tutorials/004/Makefile
@@ -27,7 +27,18 @@ include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre *.pst > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
#----------------------------------------------------------------------------
# Local targets
#----------------------------------------------------------------------------
-
diff --git a/docs/tutorials/004/combine.shar b/docs/tutorials/004/combine.shar
new file mode 100644
index 00000000000..e77f85b0df4
--- /dev/null
+++ b/docs/tutorials/004/combine.shar
@@ -0,0 +1,216 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 1999-01-17 14:31 EST by <jcej@chiroptera.tragus.org>.
+# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/004'.
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 591 -rw-rw-r-- hdr
+# 18 -rw-rw-r-- bodies
+# 702 -rw-rw-r-- page01.pre
+# 963 -rw-rw-r-- page01.pst
+#
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+touch -am 1231235999 $$.touch >/dev/null 2>&1
+if test ! -f 1231235999 && test -f $$.touch; then
+ shar_touch=touch
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 1231235999 $$.touch
+#
+if mkdir _sh00408; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= hdr ==============
+if test -f 'hdr' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'hdr' '(file already exists)'
+else
+ $echo 'x -' extracting 'hdr' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
+<HTML>
+<HEAD>
+X <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+X <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+X <META NAME="Author" CONTENT="James CE Johnson">
+X <META NAME="Description" CONTENT="A first step towards using ACE productively">
+X <TITLE>ACE Tutorial 004</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+X
+<CENTER><B><FONT SIZE=+2>ACE Tutorial 004</FONT></B></CENTER>
+X
+<CENTER><B><FONT SIZE=+2>A much more clever Client</FONT></B></CENTER>
+X
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117142999 'hdr' &&
+ chmod 0664 'hdr' ||
+ $echo 'restore of' 'hdr' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'hdr:' 'MD5 check failed'
+f129543602285ef632d3ae560999a4db hdr
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
+ test 591 -eq "$shar_count" ||
+ $echo 'hdr:' 'original size' '591,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= bodies ==============
+if test -f 'bodies' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'bodies' '(file already exists)'
+else
+ $echo 'x -' extracting 'bodies' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
+PAGE=1
+client.cpp
+SHAR_EOF
+ $shar_touch -am 0117142999 'bodies' &&
+ chmod 0664 'bodies' ||
+ $echo 'restore of' 'bodies' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'bodies:' 'MD5 check failed'
+d02fcd98e57e40350f82497be4ac0e0c bodies
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
+ test 18 -eq "$shar_count" ||
+ $echo 'bodies:' 'original size' '18,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pre ==============
+if test -f 'page01.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
+X
+<P>Ok, so the last time around, we learned how to create a simple client
+that can send a chunk of data. A cooler thing to do is to overload
+the C++ put operator (&lt;&lt;) to put some data for us. That's what
+we're going to do this time. (This tutorial is actually where ACE_IOStream
+was born.)
+<P>
+Kirthika says:
+<UL>
+The cool thing about this "cooler" client is how we use a C++ trick for
+streaming incoming data by using the operator<<() metod. Also the
+Connector portion is wrapped in the open() method which now takes in the
+server hostname and port. The result is a cleaner-looking client which
+successfully interacts with the server, when connection is established.
+</UL>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117142999 'page01.pre' &&
+ chmod 0664 'page01.pre' ||
+ $echo 'restore of' 'page01.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pre:' 'MD5 check failed'
+74d3999cd710b35c8e6c26e558a926cb page01.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
+ test 702 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '702,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pst ==============
+if test -f 'page01.pst' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pst' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pst' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pst' &&
+<HR WIDTH="100%">
+X
+<P>Ok, now we're done with that. As you can see, it really isn't
+so hard to create an object that makes sending data much more "natural"
+than the typical send() or send_n() invocation. You can even build
+up arbitrary objects &amp; do some neat tricks with C++ templates to stream
+their data out as well. (We may go into that a little later.)
+Of course, writting the full implementation such that these streams are
+interchangable with the standard C++ ostreams is quite a bit more difficult.
+In addition, there are a lot of optimizations that this client would benefit
+from!
+X
+<P>As an exercise to the reader (don't you hate those!) I challenge you
+to write the server side of this. You can take a look at IOStream_Test
+in the ACE distribution if you get stuck...
+X
+<P>If you want to compile it yourself, here's the <A HREF="client.cpp">source</A>,
+the <A HREF="Makefile">Makefile</A>,
+and <A HREF="00SetEnv">Environment
+settings</A>.
+X
+<P>
+SHAR_EOF
+ $shar_touch -am 0117142999 'page01.pst' &&
+ chmod 0664 'page01.pst' ||
+ $echo 'restore of' 'page01.pst' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pst:' 'MD5 check failed'
+c17e7bf6d06005bb1932f1790f8929fc page01.pst
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pst'`"
+ test 963 -eq "$shar_count" ||
+ $echo 'page01.pst:' 'original size' '963,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh00408
+exit 0
diff --git a/docs/tutorials/004/page01.html b/docs/tutorials/004/page01.html
index d0e0adad6d4..1ed7799673e 100644
--- a/docs/tutorials/004/page01.html
+++ b/docs/tutorials/004/page01.html
@@ -31,54 +31,58 @@ server hostname and port. The result is a cleaner-looking client which
successfully interacts with the server, when connection is established.
</UL>
<HR WIDTH="100%">
-<PRE>/*
- We need the connector object &amp; we also bring in a simple string class.
- */
-#include "ace/SOCK_Connector.h"
-#include "ace/SString.h"
+<PRE>
-/*
+<font color=red>// $Id$</font>
+
+<font color=red>/*
+ We need the connector object & we also bring in a simple string class.
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Connector.h</font>"
+<font color=blue>#include</font> "<font color=green>ace/SString.h</font>"
+
+<font color=red>/*
In this tutorial, we extend SOCK_Stream by adding a few wrappers
around the send_n() method.
- */
+ */</font>
class Client : public ACE_SOCK_Stream
{
public:
- // Basic constructor
+ <font color=red>// Basic constructor</font>
Client(void);
- /*
+ <font color=red>/*
Construct and open() in one call. This isn't generally a good
idea because you don't have a clean way to inform the caller
when open() fails. (Unless you use C++ exceptions.)
- */
+ */</font>
Client( const char * server, u_short port );
- /*
+ <font color=red>/*
Open the connection to the server. Notice that this mirrors
the use of ACE_SOCK_Connector. By providing our own open(),
- we can hide the connector from our caller &amp; make it's interaction
+ we can hide the connector from our caller & make it's interaction
easier.
- */
+ */</font>
int open( const char * server, u_short port );
- /*
+ <font color=red>/*
These are necessary if you're going to use the constructor that
invokes open().
- */
+ */</font>
inline int initialized(void) { return initialized_; }
inline int error(void) { return error_; }
- /*
+ <font color=red>/*
This is where the coolness lies. Most C++ folks are familiar
- with "cout &lt;&lt; some-data". It's a very handy and easy way to
+ with "<font color=green>cout &lt;&lt; some-data</font>". It's a very handy and easy way to
toss data around. By adding these method calls, we're able
to do the same thing with a socket connection.
- */
- Client &amp; operator&lt;&lt;( ACE_SString &amp; str );
- Client &amp; operator&lt;&lt;( char * str );
- Client &amp; operator&lt;&lt;( int n );
+ */</font>
+ Client & operator&lt;&lt;( ACE_SString & str );
+ Client & operator&lt;&lt;( char * str );
+ Client & operator&lt;&lt;( int n );
protected:
unsigned char initialized_;
@@ -86,46 +90,46 @@ protected:
};
-/*
+<font color=red>/*
The basic constructor just sets our flags to reasonable values.
- */
-Client::Client(void)
+ */</font>
+<font color=#008888>Client::Client</font>(void)
{
initialized_ = 0;
error_ = 0;
}
-/*
+<font color=red>/*
This constructor also sets the flags but then calls open(). If the
open() fails, the flags will be set appropriately. Use the two inline
method calls initialized() and error() to check the object state after
using this constructor.
- */
-Client::Client( const char * server, u_short port )
+ */</font>
+<font color=#008888>Client::Client</font>( const char * server, u_short port )
{
initialized_ = 0;
error_ = 0;
(void)open(server,port);
}
-/*
+<font color=red>/*
Open a connection to the server. This hides the use of ACE_SOCK_Connector
from our caller. Since our caller probably doesn't care *how* we connect,
this is a good thing.
- */
-int Client::open( const char * server, u_short port )
+ */</font>
+int <font color=#008888>Client::open</font>( const char * server, u_short port )
{
- /*
+ <font color=red>/*
This is right out of Tutorial 3. The only thing we've added is to set
the initialized_ member variable on success.
- */
+ */</font>
ACE_SOCK_Connector connector;
ACE_INET_Addr addr (port, server);
if (connector.connect (*this, addr) == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1);
}
initialized_ = 1;
@@ -133,31 +137,31 @@ int Client::open( const char * server, u_short port )
return(0);
}
-/*
+<font color=red>/*
The first of our put operators sends a simple string object to the peer.
-*/
-Client &amp; Client::operator&lt;&lt;( ACE_SString &amp; str )
+*/</font>
+Client & <font color=#008888>Client::operator</font>&lt;&lt;( ACE_SString & str )
{
- /*
+ <font color=red>/*
We have to be able to allow:
server &lt;&lt; foo &lt;&lt; bar &lt;&lt; stuff;
To accomplish that, every &lt;&lt; operator must check that the object is
in a valid state before doing work.
- */
+ */</font>
- if( initialized() &amp;&amp; ! error() )
+ if( initialized() && ! error() )
{
- /*
+ <font color=red>/*
Get the actual data held in the string object
- */
- char * cp = str.rep();
+ */</font>
+ const char * cp = str.rep();
- /*
+ <font color=red>/*
Send that data to the peer using send_n() as before. If we have
a problem, we'll set error_ so that subsequent &lt;&lt; operations won't
try to use a broken stream.
- */
+ */</font>
if( this->send_n(cp,strlen(cp)) == -1 )
{
error_ = 1;
@@ -165,29 +169,29 @@ Client &amp; Client::operator&lt;&lt;( ACE_SString &amp; str )
}
else
{
- /*
+ <font color=red>/*
Be sure that error_ is set if somebody tries to use us when
we're not initialized.
- */
+ */</font>
error_ = 1;
}
- /*
+ <font color=red>/*
We have to return a reference to ourselves to allow chaining of
- put operations (eg -- "server &lt;&lt; foo &lt;&lt; bar"). Without the reference,
+ put operations (eg -- "<font color=green>server &lt;&lt; foo &lt;&lt; bar</font>"). Without the reference,
you would have to do each put operation as a statement. That's OK
but doesn't have the same feel as standard C++ iostreams.
- */
+ */</font>
return *this ;
}
-/*
+<font color=red>/*
How do you put a char*? We'll take an easy way out and construct an ACE_SString
from the char* and then put that. It would have been more efficient to implement
-this with the body of the operator&lt;&lt;(ACE_SString&amp;) method and then express that
+this with the body of the operator&lt;&lt;(ACE_SString&) method and then express that
method in terms of this one. There's always more than one way to do things!
- */
-Client &amp; Client::operator&lt;&lt; ( char * str )
+ */</font>
+Client & <font color=#008888>Client::operator</font>&lt;&lt; ( char * str )
{
ACE_SString newStr(str);
@@ -195,104 +199,104 @@ Client &amp; Client::operator&lt;&lt; ( char * str )
return *this ;
- /*
+ <font color=red>/*
Notice that we could have been really clever and done:
return *this &lt;&lt; ACE_SString(str);
That kind of thing just makes debugging a pain though!
- */
+ */</font>
}
-/*
+<font color=red>/*
ACE_SString and char* are both about the same thing. What do you do about
different datatypes though?
Do the same thing we did with char* and convert it to ACE_SString where we
already have a &lt;&lt; operator defined.
- */
-Client &amp; Client::operator&lt;&lt; ( int n )
+ */</font>
+Client & <font color=#008888>Client::operator</font>&lt;&lt; ( int n )
{
- /*
+ <font color=red>/*
Create a character buffer large enough for the largest number. That's
a tough call but 1024 should be quite enough.
- */
+ */</font>
char buf[1024];
- /*
+ <font color=red>/*
Put the number into our buffer...
- */
- ACE_OS::sprintf(buf,"(%d)\n",n);
+ */</font>
+ <font color=#008888>ACE_OS::sprintf</font>(buf,"<font color=green>(%d)\n</font>",n);
- /*
+ <font color=red>/*
And create the ACE_SString that we know how to put.
- */
+ */</font>
ACE_SString newStr(buf);
- /*
+ <font color=red>/*
Send it and...
- */
+ */</font>
*this &lt;&lt; newStr;
- /*
+ <font color=red>/*
return ourselves as usual.
- */
+ */</font>
return *this;
}
-/*
+<font color=red>/*
Now we pull it all together. Like Tutorial 3, we'll allow command line options.
- */
+ */</font>
int main (int argc, char *argv[])
{
const char *server_host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST;
- u_short server_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT;
- int max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : 4;
+ u_short server_port = argc > 2 ? <font color=#008888>ACE_OS::atoi</font> (argv[2]) : ACE_DEFAULT_SERVER_PORT;
+ int max_iterations = argc > 3 ? <font color=#008888>ACE_OS::atoi</font> (argv[3]) : 4;
- /*
+ <font color=red>/*
Use the basic constructor since the other isn't really very safe.
- */
+ */</font>
Client server;
- /*
+ <font color=red>/*
Open the server connection. Notice how this is simpler than Tutorial 3
since we only have to provide a host name and port value.
- */
+ */</font>
if( server.open(server_host,server_port) == -1 )
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1);
}
for (int i = 0; i &lt; max_iterations; i++)
{
- /*
+ <font color=red>/*
Tell the server which iteration we're on. No more mucking aroudn with
sprintf at this level! It's all hidden from us.
- */
- server &lt;&lt; "message = " &lt;&lt; i+1;
+ */</font>
+ server &lt;&lt; "<font color=green>message = </font>" &lt;&lt; i+1;
- /*
+ <font color=red>/*
Everything OK?
- */
+ */</font>
if ( server.error() )
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>send</font>"), -1);
}
else
{
- ACE_OS::sleep (1);
+ <font color=#008888>ACE_OS::sleep</font> (1);
}
}
if (server.close () == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>close</font>"), -1);
}
return 0;
-}</PRE>
-
+}
+</PRE>
<HR WIDTH="100%">
<P>Ok, now we're done with that. As you can see, it really isn't
@@ -315,9 +319,5 @@ and <A HREF="00SetEnv">Environment
settings</A>.
<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/005/Makefile b/docs/tutorials/005/Makefile
index 6c4b01dbf9c..8c0f9a91a3c 100644
--- a/docs/tutorials/005/Makefile
+++ b/docs/tutorials/005/Makefile
@@ -83,11 +83,23 @@ Indent : #
# stuff back out of the Makefile and into a file ".depend" which we then
# include just like the makefile components above.
Depend : depend
- perl fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
+
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
diff --git a/docs/tutorials/005/acceptor b/docs/tutorials/005/acceptor
deleted file mode 100644
index 45409e4ec3e..00000000000
--- a/docs/tutorials/005/acceptor
+++ /dev/null
@@ -1,6 +0,0 @@
-
-1. #include "ace/Acceptor.h"
-2. #include "ace/SOCK_Acceptor.h"
-
-3. typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> Logging_Acceptor;
-
diff --git a/docs/tutorials/005/combine.shar b/docs/tutorials/005/combine.shar
new file mode 100644
index 00000000000..8bdd7c46422
--- /dev/null
+++ b/docs/tutorials/005/combine.shar
@@ -0,0 +1,423 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 1999-01-17 14:53 EST by <jcej@chiroptera.tragus.org>.
+# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/005'.
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 598 -rw-rw-r-- hdr
+# 97 -rw-rw-r-- bodies
+# 628 -rw-rw-r-- page01.pre
+# 512 -rw-rw-r-- page02.pre
+# 686 -rw-rw-r-- page03.pre
+# 464 -rw-rw-r-- page04.pre
+# 218 -rw-rw-r-- page05.pre
+# 98 -rw-rw-r-- page06.pre
+# 172 -rw-rw-r-- page07.pre
+# 715 -rw-rw-r-- page08.pre
+#
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+touch -am 1231235999 $$.touch >/dev/null 2>&1
+if test ! -f 1231235999 && test -f $$.touch; then
+ shar_touch=touch
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 1231235999 $$.touch
+#
+if mkdir _sh00760; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= hdr ==============
+if test -f 'hdr' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'hdr' '(file already exists)'
+else
+ $echo 'x -' extracting 'hdr' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
+<HTML>
+<HEAD>
+X <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+X <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+X <META NAME="Author" CONTENT="Billy Quinn">
+X <META NAME="Description" CONTENT="A first step towards using ACE productively">
+X <TITLE>ACE Tutorial 005</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
+X
+<CENTER><B><FONT SIZE=+2>ACE Tutorial 005</FONT></B></CENTER>
+X
+<CENTER><B><FONT SIZE=+2>On the road to a multithreaded server</FONT></B></CENTER>
+X
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117143899 'hdr' &&
+ chmod 0664 'hdr' ||
+ $echo 'restore of' 'hdr' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'hdr:' 'MD5 check failed'
+197a3d789965f9c046d4d84ee137ace9 hdr
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
+ test 598 -eq "$shar_count" ||
+ $echo 'hdr:' 'original size' '598,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= bodies ==============
+if test -f 'bodies' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'bodies' '(file already exists)'
+else
+ $echo 'x -' extracting 'bodies' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
+PAGE=2
+server.cpp
+client_acceptor.h
+client_handler.h
+client_handler.cpp
+Makefile
+X../fix.Makefile
+SHAR_EOF
+ $shar_touch -am 0117143799 'bodies' &&
+ chmod 0664 'bodies' ||
+ $echo 'restore of' 'bodies' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'bodies:' 'MD5 check failed'
+dcbb8d7d85345e022a122f4f7fa10fb9 bodies
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
+ test 97 -eq "$shar_count" ||
+ $echo 'bodies:' 'original size' '97,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page01.pre ==============
+if test -f 'page01.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page01.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
+X
+<P>In this tutorial, we're going to flash-back to the simple server we
+created a while back.&nbsp; We'll create a very simple server where everything
+takes place in one thread.&nbsp; Once we have a solid understanding there,
+we'll move on to the next tutorial where we begin to introduce concurrency
+concepts.
+X
+<P>There are four C++&nbsp;source files in this tutorial:&nbsp; server.cpp,
+client_acceptor.h, client_handler.h and client_handler.cpp.&nbsp; I'll
+talk about each of these in turn with the usual color commentary as we
+go.&nbsp; In addition, I'll briefly discuss the Makefile and a short perl
+script I've added.
+X
+<P>
+SHAR_EOF
+ $shar_touch -am 0117143899 'page01.pre' &&
+ chmod 0664 'page01.pre' ||
+ $echo 'restore of' 'page01.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page01.pre:' 'MD5 check failed'
+b819665dcbed1ef2efe12bdc8d8710c5 page01.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
+ test 628 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '628,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page02.pre ==============
+if test -f 'page02.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page02.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page02.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page02.pre' &&
+X
+<P>We begin with <I><A HREF="server.cpp">server.cpp</A></I>.
+<P>
+Abstraction by Kirthika:
+<UL>
+This tutorial is a re-cap of the client-server hookup tutorial with much
+X cleaner code (for instance: use of destroy() to delete objects and
+process() which does the task of reading in data from the client).
+<P>
+We again enroll the services of the reactor to handle events. Everything
+occurs in a single thread.
+<P>
+This tutorial is a stepping stone towards a mutithreaded server model.
+</ul>
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117143899 'page02.pre' &&
+ chmod 0664 'page02.pre' ||
+ $echo 'restore of' 'page02.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page02.pre:' 'MD5 check failed'
+b8413e5ef19a9a56971d419e90f14b51 page02.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pre'`"
+ test 512 -eq "$shar_count" ||
+ $echo 'page02.pre:' 'original size' '512,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page03.pre ==============
+if test -f 'page03.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page03.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page03.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page03.pre' &&
+X
+<P>Now, let's take a look at <I><A HREF="client_acceptor.h">client_acceptor.h</A></I>.&nbsp;
+Since I went on about how it does all the work of letting clients connect
+to us, it must be rather complext.&nbsp; Right?&nbsp; Wrong.
+X
+<P>The more you use ACE, the more you'll find that they've already taken
+care of most details for you.&nbsp; With respect to the acceptance of client
+connections:&nbsp; there just aren't that many ways to do it!&nbsp; The
+ACE team has chosen an approach and created a C++&nbsp;template that does
+all of the work for you.&nbsp; All you're required to do is provide it
+with an object type to instantiate when a new connection arrives.
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117143899 'page03.pre' &&
+ chmod 0664 'page03.pre' ||
+ $echo 'restore of' 'page03.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page03.pre:' 'MD5 check failed'
+e9d33d562522df5623cd6bcea010a9c6 page03.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pre'`"
+ test 686 -eq "$shar_count" ||
+ $echo 'page03.pre:' 'original size' '686,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page04.pre ==============
+if test -f 'page04.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page04.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page04.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page04.pre' &&
+X
+<P>Ok, so we've got a main() loop that sets up the acceptor and we've seen
+how easy it is to create the acceptor object.&nbsp; So far, we've hardly
+written any code at all.&nbsp; Well, that's just about to change...
+X
+<P>First, we look at <I><A HREF="client_handler.h">client_handler.h</A></I>
+for the declaration of the Client_Handler object.&nbsp; Then we look at
+the definition where all of the real work of the application takes place.
+X
+<P>
+<HR WIDTH="100%">
+X
+SHAR_EOF
+ $shar_touch -am 0117143899 'page04.pre' &&
+ chmod 0664 'page04.pre' ||
+ $echo 'restore of' 'page04.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page04.pre:' 'MD5 check failed'
+3a0e0d0c79318ca18dd5920dd97ca834 page04.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pre'`"
+ test 464 -eq "$shar_count" ||
+ $echo 'page04.pre:' 'original size' '464,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page05.pre ==============
+if test -f 'page05.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page05.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page05.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page05.pre' &&
+X
+<P>Now we're finally at <I><A HREF="client_handler.cpp">client_handler.cpp</A></I>
+where we have to write some code.&nbsp; This file has more code than the
+rest of the application all together.
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117143899 'page05.pre' &&
+ chmod 0664 'page05.pre' ||
+ $echo 'restore of' 'page05.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page05.pre:' 'MD5 check failed'
+d5fa96547c3b94abc387c8b87f2f3c92 page05.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page05.pre'`"
+ test 218 -eq "$shar_count" ||
+ $echo 'page05.pre:' 'original size' '218,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page06.pre ==============
+if test -f 'page06.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page06.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page06.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page06.pre' &&
+X
+<P>Before we go, I wanted you to see the <A HREF="Makefile">Makefile</A>.
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117143899 'page06.pre' &&
+ chmod 0664 'page06.pre' ||
+ $echo 'restore of' 'page06.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page06.pre:' 'MD5 check failed'
+b8a35eb354a8e5c90155dd728a8bfa4e page06.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page06.pre'`"
+ test 98 -eq "$shar_count" ||
+ $echo 'page06.pre:' 'original size' '98,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page07.pre ==============
+if test -f 'page07.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page07.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page07.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page07.pre' &&
+X
+<P>And last (and probably least) is the <A HREF="../fix.Makefile">perl script</A>
+that pulls the dependency stuff out of Makefile and into .depend.
+X
+<P>
+<HR WIDTH="100%">
+SHAR_EOF
+ $shar_touch -am 0117144099 'page07.pre' &&
+ chmod 0664 'page07.pre' ||
+ $echo 'restore of' 'page07.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page07.pre:' 'MD5 check failed'
+7f896dc992a365d4d095d0a6d3b9eb47 page07.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page07.pre'`"
+ test 172 -eq "$shar_count" ||
+ $echo 'page07.pre:' 'original size' '172,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= page08.pre ==============
+if test -f 'page08.pre' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING 'page08.pre' '(file already exists)'
+else
+ $echo 'x -' extracting 'page08.pre' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'page08.pre' &&
+X
+<P>That's it for Tutorial 5.&nbsp; In this tutorial we've built a single-threaded
+reactor-based server.&nbsp; We've done a couple of things that aren't exactly
+necessary for such an implementation but I&nbsp;plan to build on that as
+we explore two other concurrency strategies:&nbsp; thread per connection
+and thread pool.
+X
+<P>For reference, here's the file list again:
+<UL>
+<LI>
+<A HREF="Makefile">Makefile</A></LI>
+X
+<LI>
+<A HREF="client_acceptor.h">client_acceptor.h</A></LI>
+X
+<LI>
+<A HREF="client_handler.cpp">client_handler.cpp</A></LI>
+X
+<LI>
+<A HREF="client_handler.h">client_handler.h</A></LI>
+X
+<LI>
+<A HREF="server.cpp">server.cpp</A></LI>
+X
+<LI>
+<A HREF="../fix.Makefile">fix.Makefile</A></LI>
+</UL>
+&nbsp;
+SHAR_EOF
+ $shar_touch -am 0117143899 'page08.pre' &&
+ chmod 0664 'page08.pre' ||
+ $echo 'restore of' 'page08.pre' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo 'page08.pre:' 'MD5 check failed'
+678ef0c3162d2a2739d0efdcfeac5cb9 page08.pre
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page08.pre'`"
+ test 715 -eq "$shar_count" ||
+ $echo 'page08.pre:' 'original size' '715,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh00760
+exit 0
diff --git a/docs/tutorials/005/fix.Makefile b/docs/tutorials/005/fix.Makefile
deleted file mode 100644
index e99c194114a..00000000000
--- a/docs/tutorials/005/fix.Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/perl
-
- # Open the Makefile that has been mangled by 'make depend'
- # and suck it into a perl array.
-open(IF,"<Makefile") || die;
-@makefile = <IF>;
-close(IF);
-
- # Now open our .depend file and a temporary Makefile.
- # We'll split the original Makefile between these two.
-open(DF,">.depend") || die;
-open(MF,">Makefile.tmp") || die;
-
- # For each line we read out of the original file...
-foreach (@makefile) {
-
- # If we're into the dependency section, write the line
- # into the .depend file.
- #
- if( $depend ) {
- print DF $_;
- }
- else {
- # If we haven't gotten to the dependency section yet
- # then see if the current line is the separator that
- # "make depend" causes to be inserted.
- #
- if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {
-
- # If so, change our "mode" and skip this line.
- ++$depend;
- next;
- }
-
- # Also skip the "include .depend" that we insert. If we
- # don't do this, it is possible to have a bunch of these
- # inserted into the output when we read an unmangled Makefile
- next if( m/^include .depend/ );
-
- # Print the non-dependency info to the temporary Makefile
- print MF $_;
- }
-}
-
-# Tell our new Makefile to include the dependency file
-print MF "include .depend\n";
-
-# Close the two output files...
-close(DF);
-close(MF);
-
-# Unlink (remove) the original Makefile and rename our
-# temporary file. There's obviously room for error checking
-# here but we've got the Makefile checked into some revision
-# control system anyway. Don't we?
-
-unlink("Makefile");
-rename("Makefile.tmp","Makefile");
-
-exit(0);
diff --git a/docs/tutorials/005/handler b/docs/tutorials/005/handler
deleted file mode 100644
index d987f4c34ff..00000000000
--- a/docs/tutorials/005/handler
+++ /dev/null
@@ -1,81 +0,0 @@
-
-1. #include "ace/SOCK_Acceptor.h"
-2. #include "ace/Reactor.h"
-
-
-3. class Logging_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
- {
-
- public:
-
-4. Logging_Handler (void)
- {
- }
-
-5. virtual void destroy (void)
- {
-6. g_reactor->cancel_timer (this);
-7. this->peer ().close ();
- }
-
-8. virtual int open (void *)
- {
-9. ACE_INET_Addr addr;
-
-10. if (this->peer ().get_remote_addr (addr) == -1)
-11. return -1;
-12. else
- {
-13. ACE_OS::strncpy (this->peer_name_, addr.get_host_name (), MAXHOSTNAMELEN + 1);
-
-14. if (g_reactor->register_handler(this, ACE_Event_Handler::READ_MASK) == -1)
-15. ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1);
-
-16. else if (g_reactor->schedule_timer (this, (const void *) this, ACE_Time_Value (2), ACE_Time_Value (2)) == -1)
-17. ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1);
-
-18. else
-19. ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->peer_name_));
-
-20. return 0;
- }
- }
-
-21. virtual int close (u_long)
- {
-22. this->destroy ();
-23. return 0;
- }
-
- protected:
-
-24. virtual int handle_input (ACE_HANDLE)
- {
-25. char buf[128];
-26. memset(buf,0,sizeof(buf));
-
-27. switch( this->peer().recv(buf,sizeof buf) )
- {
-28. case -1:
-29. ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p bad read\n", "client logger"), -1);
-30. case 0:
-31. ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon (fd = %d)\n", this->get_handle ()), -1);
-32. default:
-33. ACE_DEBUG ((LM_DEBUG, "(%P|%t) from client: %s",buf));
- }
-
-34. return 0;
- }
-
-35. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg)
- {
-36. ACE_ASSERT (arg == this);
-37. ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this));
-38. return 0;
- }
-
- private:
-
-39. char peer_name_[MAXHOSTNAMELEN + 1];
-
- };
diff --git a/docs/tutorials/005/main b/docs/tutorials/005/main
deleted file mode 100644
index 36c67561463..00000000000
--- a/docs/tutorials/005/main
+++ /dev/null
@@ -1,36 +0,0 @@
-1. #include "ace/Reactor.h"
-
-2. ACE_Reactor * g_reactor;
-
-3. static sig_atomic_t finished = 0;
-4. extern "C" void handler (int) { finished = 1; }
-
-5. static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
-
-6. int main (int argc, char *argv[])
- {
-7. g_reactor = new ACE_Reactor;
-
- // Acceptor factory.
-8. Logging_Acceptor peer_acceptor;
-
-9. if (peer_acceptor.open (ACE_INET_Addr (PORT)) == -1)
-10. ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
-
-11. else if (g_reactor->register_handler (&peer_acceptor, ACE_Event_Handler::READ_MASK) == -1)
-12. ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1);
-
-13. ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
-
- // Run forever, performing logging service.
-
-14. ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n"));
-
- // Perform logging service until QUIT_HANDLER receives SIGINT.
-15. while ( !finished )
-16. g_reactor->handle_events ();
-
-17. ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n"));
-
-18. return 0;
- }
diff --git a/docs/tutorials/005/page01.html b/docs/tutorials/005/page01.html
index 60ae178abf3..90a5da1e1f4 100644
--- a/docs/tutorials/005/page01.html
+++ b/docs/tutorials/005/page01.html
@@ -29,10 +29,5 @@ go.&nbsp; In addition, I'll briefly discuss the Makefile and a short perl
script I've added.
<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page02.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page02.html b/docs/tutorials/005/page02.html
index 65436ea9962..d3e87eb5873 100644
--- a/docs/tutorials/005/page02.html
+++ b/docs/tutorials/005/page02.html
@@ -31,182 +31,128 @@ This tutorial is a stepping stone towards a mutithreaded server model.
</ul>
<P>
<HR WIDTH="100%">
-
-<P><FONT FACE="Arial,Helvetica">// $Id: server.cpp,v 1.5 1998/08/29 21:57:32
-jcej Exp $</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; We try to keep main() very
-simple.&nbsp; One of the ways we do that is to push</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; much of the complicated stuff
-into worker objects.&nbsp; In this case, we only</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; need to include the acceptor
-header in our main source file.&nbsp; We let it</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; worry about the "real work".</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">#include "client_acceptor.h"</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; As before, we create a simple
-signal handler that will set our finished</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; flag.&nbsp; There are, of
-course, more elegant ways to handle program shutdown</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; requests but that isn't really
-our focus right now, so we'll just do the</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; easiest thing.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">static sig_atomic_t finished = 0;</FONT>
-<BR><FONT FACE="Arial,Helvetica">extern "C" void handler (int)</FONT>
-<BR><FONT FACE="Arial,Helvetica">{</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; finished = 1;</FONT>
-<BR><FONT FACE="Arial,Helvetica">}</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; A server has to listen for
-clients at a known TCP/IP port.&nbsp; The default ACE</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; port is 10002 (at least on
-my system) and that's good enough for what&nbsp; we</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; want to do here.&nbsp; Obviously,
-a more robust application would take a command</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; line parameter or read from
-a configuration file or do some other&nbsp; clever</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; thing.&nbsp; Just like the
-signal handler above, though, that's not what we want to</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; focus on, so we're taking
-the easy way out.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">static const u_short PORT = ACE_DEFAULT_SERVER_PORT;</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; Finally, we get to main.&nbsp;
-Some C++ compilers will complain loudly if your</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; function signature doesn't
-match the prototype.&nbsp; Even though we're not</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; going to use the parameters,
-we still&nbsp; have to specify them.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">int main (int argc, char *argv[])</FONT>
-<BR><FONT FACE="Arial,Helvetica">{</FONT>
-<BR><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; In our earlier servers, we
-used a global pointer to get to the reactor. I've</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; never really liked that idea,
-so I've moved it into main() this time. When</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; we&nbsp; get to the Client_Handler
-object you'll see how we manage to get a</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; pointer back to this reactor.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; ACE_Reactor reactor;</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; The acceptor
-will take care of letting clients connect to us.&nbsp; It will</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; also arrange
-for a&nbsp; Client_Handler to be created for each new client.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Since we're only
-going to listen at one&nbsp; TCP/IP port, we only need one</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; acceptor.&nbsp;
-If we wanted, though, we could create several of these&nbsp; and</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; listen at several
-ports.&nbsp; (That's what we would do if we wanted to rewrite</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; inetd for&nbsp;
-instance.)</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; Client_Acceptor peer_acceptor;</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Create an ACE_INET_Addr
-that represents our endpoint of a connection. We</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; then open our
-acceptor object with that Addr.&nbsp; Doing so tells the acceptor</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; where to listen
-for connections.&nbsp; Servers generally listen at "well known"</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; addresses.&nbsp;
-If not, there must be some mechanism by which the client is</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; informed of the
-server's address.</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Note how ACE_ERROR_RETURN
-is used if we fail to open the acceptor.&nbsp; This</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; technique is
-used over and over again in our tutorials.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; if (peer_acceptor.open (ACE_INET_Addr
-(PORT), &amp;reactor) == -1)</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp; ACE_ERROR_RETURN ((LM_ERROR,
-"%p\n", "open"), -1);</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Here, we know
-that the open was successful.&nbsp; If it had failed, we would</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; have exited above.&nbsp;
-A nice side-effect of the open() is that we're already</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; registered with
-the reactor we provided it.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Install our signal
-handler.&nbsp; You can actually register signal handlers</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; with the reactor.&nbsp;
-You might do that when the signal handler is</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; responsible for
-performing "real" work.&nbsp; Our simple flag-setter doesn't</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; justify deriving
-from ACE_Event_Handler and providing a callback function</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; though.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; ACE_Sig_Action sa ((ACE_SignalHandler)
-handler, SIGINT);</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; Like ACE_ERROR_RETURN,
-the ACE_DEBUG macro gets used quite a bit.&nbsp; It's a</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; handy way to
-generate uniform debug output from your program.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; ACE_DEBUG ((LM_DEBUG, "(%P|%t)
-starting up server daemon\n"));</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; /*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; This will loop
-"forever" invoking the handle_events() method of our</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; reactor. handle_events()
-watches for activity on any registered handlers</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; and invokes their
-appropriate callbacks when necessary.&nbsp; Callback-driven</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; programming is
-a big thing in ACE, you should get used to it. If the</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; signal handler
-catches something, the finished flag will be set and we'll</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; exit.&nbsp; Conveniently
-enough, handle_events() is also interrupted by signals</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; and will exit
-back to the while() loop.&nbsp; (If you want your event loop to</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; not be interrupted
-by signals, checkout the &lt;i>restart&lt;/i> flag on the</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp; open() method
-of ACE_Reactor if you're interested.)</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp; */</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp; while (!finished)</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp; reactor.handle_events
-();</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting
-down server daemon\n"));</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp; return 0;</FONT>
-<BR><FONT FACE="Arial,Helvetica">}</FONT>
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page03.html">Continue
-This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<PRE>
+<font color=red>// $Id$</font>
+
+<font color=red>/*
+ We try to keep main() very simple. One of the ways we do that is to push
+ much of the complicated stuff into worker objects. In this case, we only
+ need to include the acceptor header in our main source file. We let it
+ worry about the "<font color=green>real work</font>".
+ */</font>
+
+<font color=blue>#include</font> "<font color=green>client_acceptor.h</font>"
+
+<font color=red>/*
+ As before, we create a simple signal handler that will set our finished
+ flag. There are, of course, more elegant ways to handle program shutdown
+ requests but that isn't really our focus right now, so we'll just do the
+ easiest thing.
+ */</font>
+
+static sig_atomic_t finished = 0;
+extern "<font color=green>C</font>" void handler (int)
+{
+ finished = 1;
+}
+
+<font color=red>/*
+ A server has to listen for clients at a known TCP/IP port. The default ACE
+ port is 10002 (at least on my system) and that's good enough for what we
+ want to do here. Obviously, a more robust application would take a command
+ line parameter or read from a configuration file or do some other clever
+ thing. Just like the signal handler above, though, that's not what we want to
+ focus on, so we're taking the easy way out.
+ */</font>
+
+static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
+
+<font color=red>/*
+ Finally, we get to main. Some C++ compilers will complain loudly if your
+ function signature doesn't match the prototype. Even though we're not
+ going to use the parameters, we still have to specify them.
+ */</font>
+
+int main (int argc, char *argv[])
+{
+<font color=red>/*
+ In our earlier servers, we used a global pointer to get to the reactor. I've
+ never really liked that idea, so I've moved it into main() this time. When
+ we get to the Client_Handler object you'll see how we manage to get a
+ pointer back to this reactor.
+ */</font>
+ ACE_Reactor reactor;
+
+ <font color=red>/*
+ The acceptor will take care of letting clients connect to us. It will
+ also arrange for a Client_Handler to be created for each new client.
+ Since we're only going to listen at one TCP/IP port, we only need one
+ acceptor. If we wanted, though, we could create several of these and
+ listen at several ports. (That's what we would do if we wanted to rewrite
+ inetd for instance.)
+ */</font>
+ Client_Acceptor peer_acceptor;
+
+ <font color=red>/*
+ Create an ACE_INET_Addr that represents our endpoint of a connection. We
+ then open our acceptor object with that Addr. Doing so tells the acceptor
+ where to listen for connections. Servers generally listen at "<font color=green>well known</font>"
+ addresses. If not, there must be some mechanism by which the client is
+ informed of the server's address.
+
+ Note how ACE_ERROR_RETURN is used if we fail to open the acceptor. This
+ technique is used over and over again in our tutorials.
+ */</font>
+ if (peer_acceptor.open (ACE_INET_Addr (PORT), &reactor) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1);
+
+ <font color=red>/*
+ Here, we know that the open was successful. If it had failed, we would
+ have exited above. A nice side-effect of the open() is that we're already
+ registered with the reactor we provided it.
+ */</font>
+
+ <font color=red>/*
+ Install our signal handler. You can actually register signal handlers
+ with the reactor. You might do that when the signal handler is
+ responsible for performing "<font color=green>real</font>" work. Our simple flag-setter doesn't
+ justify deriving from ACE_Event_Handler and providing a callback function
+ though.
+ */</font>
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
+
+ <font color=red>/*
+ Like ACE_ERROR_RETURN, the ACE_DEBUG macro gets used quite a bit. It's a
+ handy way to generate uniform debug output from your program.
+ */</font>
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) starting up server daemon\n</font>"));
+
+ <font color=red>/*
+ This will loop "<font color=green>forever</font>" invoking the handle_events() method of our
+ reactor. handle_events() watches for activity on any registered handlers
+ and invokes their appropriate callbacks when necessary. Callback-driven
+ programming is a big thing in ACE, you should get used to it. If the
+ signal handler catches something, the finished flag will be set and we'll
+ exit. Conveniently enough, handle_events() is also interrupted by signals
+ and will exit back to the while() loop. (If you want your event loop to
+ not be interrupted by signals, checkout the &lt;i>restart&lt;/i> flag on the
+ open() method of ACE_Reactor if you're interested.)
+ */</font>
+ while (!finished)
+ reactor.handle_events ();
+
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) shutting down server daemon\n</font>"));
+
+ return 0;
+}
+
+<font color=blue>#if defined</font> (<font color=purple>ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION</font>)
+template class ACE_Acceptor &lt;Client_Handler, ACE_SOCK_ACCEPTOR>;
+template class ACE_Svc_Handler&lt;ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
+<font color=blue>#elif defined</font> (<font color=purple>ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA</font>)
+<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Acceptor &lt;Client_Handler, ACE_SOCK_ACCEPTOR>
+<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Svc_Handler&lt;ACE_SOCK_STREAM, ACE_NULL_SYNCH>
+<font color=blue>#endif</font> <font color=red>/* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */</font>
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page03.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page03.html b/docs/tutorials/005/page03.html
index fb8acc3e913..20c80328703 100644
--- a/docs/tutorials/005/page03.html
+++ b/docs/tutorials/005/page03.html
@@ -29,66 +29,52 @@ with an object type to instantiate when a new connection arrives.
<P>
<HR WIDTH="100%">
-
-<P><FONT FACE="Arial,Helvetica">// $Id$</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">#ifndef&nbsp; CLIENT_ACCEPTOR_H</FONT>
-<BR><FONT FACE="Arial,Helvetica">#define CLIENT_ACCEPTOR_H</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;The ACE_Acceptor&lt;> template lives
-in the ace/Acceptor.h header file.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;You'll find a very consitent naming
-convention between the ACE objects</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;and the headers where they can be
-found.&nbsp; In general, the ACE object</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;<I>ACE_Foobar</I> will be found
-in <I>ace/Foobar.h</I>.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">#include "ace/Acceptor.h"</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;Since we want to work with sockets,
-we'll need a SOCK_Acceptor to allow</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;the clients to connect to us.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT>
-<BR><FONT FACE="Arial,Helvetica">#include "ace/SOCK_Acceptor.h"</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;The Client_Handler object we develop
-will be used to handle clients</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;once they're connected.&nbsp; The
-ACE_Acceptor&lt;> template's first parameter</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;requires such an object.&nbsp; In
-some cases, you can get by with just a</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;forward declaration on the class,
-in others you have to have the whole</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;thing.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT>
-<BR><FONT FACE="Arial,Helvetica">#include "client_handler.h"</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">/*</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;Parameterize the ACE_Acceptor&lt;>
-such that it will listen for socket</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;connection attempts and create Client_Handler
-objects when they happen.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;In Tutorial 001, we wrote the basic
-acceptor logic on our own before</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;we realized that ACE_Acceptor&lt;>
-was available.&nbsp; You'll get spoiled using</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;the ACE templates because they take
-away a lot of the tedious details!</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;*/</FONT>
-<BR><FONT FACE="Arial,Helvetica">typedef ACE_Acceptor &lt; Client_Handler,
-ACE_SOCK_ACCEPTOR > Client_Acceptor;</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">#endif // CLIENT_ACCEPTOR_H</FONT>
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page04.html">Continue This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<PRE>
+
+<font color=red>// $Id$</font>
+
+<font color=blue>#ifndef</font> <font color=purple>CLIENT_ACCEPTOR_H</font>
+<font color=blue>#define</font> <font color=purple>CLIENT_ACCEPTOR_H</font>
+
+<font color=red>/*
+ The ACE_Acceptor&lt;> template lives in the ace/Acceptor.h header file. You'll
+ find a very consitent naming convention between the ACE objects and the
+ headers where they can be found. In general, the ACE object ACE_Foobar will
+
+
+ be found in ace/Foobar.h.
+ */</font>
+
+<font color=blue>#include</font> "<font color=green>ace/Acceptor.h</font>"
+
+<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
+# pragma once
+<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
+
+<font color=red>/*
+ Since we want to work with sockets, we'll need a SOCK_Acceptor to allow the
+ clients to connect to us.
+ */</font>
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Acceptor.h</font>"
+
+<font color=red>/*
+ The Client_Handler object we develop will be used to handle clients once
+ they're connected. The ACE_Acceptor&lt;> template's first parameter requires
+ such an object. In some cases, you can get by with just a forward
+ declaration on the class, in others you have to have the whole thing.
+ */</font>
+<font color=blue>#include</font> "<font color=green>client_handler.h</font>"
+
+<font color=red>/*
+ Parameterize the ACE_Acceptor&lt;> such that it will listen for socket
+ connection attempts and create Client_Handler objects when they happen. In
+ Tutorial 001, we wrote the basic acceptor logic on our own before we
+ realized that ACE_Acceptor&lt;> was available. You'll get spoiled using the
+ ACE templates because they take away a lot of the tedious details!
+ */</font>
+typedef ACE_Acceptor &lt; Client_Handler, ACE_SOCK_ACCEPTOR > Client_Acceptor;
+
+<font color=blue>#endif</font> <font color=red>// CLIENT_ACCEPTOR_H</font>
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page04.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page04.html b/docs/tutorials/005/page04.html
index 95f2ce5a393..c5eb21cda31 100644
--- a/docs/tutorials/005/page04.html
+++ b/docs/tutorials/005/page04.html
@@ -1,10 +1,10 @@
<HTML>
<HEAD>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
-<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
-<META NAME="Author" CONTENT="Billy Quinn">
-<META NAME="Description" CONTENT="A first step towards using ACE productively">
-<TITLE>ACE Tutorial 005</TITLE>
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+ <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
+ <META NAME="Author" CONTENT="Billy Quinn">
+ <META NAME="Description" CONTENT="A first step towards using ACE productively">
+ <TITLE>ACE Tutorial 005</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
@@ -27,11 +27,14 @@ the definition where all of the real work of the application takes place.
<P>
<HR WIDTH="100%">
-<pre><FONT FACE="Arial,Helvetica">
-#ifndef CLIENT_HANDLER_H
-#define CLIENT_HANDLER_H
+<PRE>
-/*
+<font color=red>// $Id$</font>
+
+<font color=blue>#ifndef</font> <font color=purple>CLIENT_HANDLER_H</font>
+<font color=blue>#define</font> <font color=purple>CLIENT_HANDLER_H</font>
+
+<font color=red>/*
Our client handler must exist somewhere in the ACE_Event_Handler object
hierarchy. This is a requirement of the ACE_Reactor because it maintains
ACE_Event_Handler pointers for each registered event handler. You could
@@ -41,53 +44,53 @@ the definition where all of the real work of the application takes place.
ACE_SOCK_Stream instance yourself. With ACE_Svc_Handler (which is a
derivative of ACE_Event_Handler) some of those details are handled for you.
- */
+ */</font>
-#include "ace/Svc_Handler.h"
+<font color=blue>#include</font> "<font color=green>ace/Svc_Handler.h</font>"
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
+<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
+<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-#include "ace/SOCK_Stream.h"
+<font color=blue>#include</font> "<font color=green>ace/SOCK_Stream.h</font>"
-/*
- Another feature of ACE_Svc_Handler is it's ability to present the ACE_Task<>
+<font color=red>/*
+ Another feature of ACE_Svc_Handler is it's ability to present the ACE_Task&lt;>
interface as well. That's what the ACE_NULL_SYNCH parameter below is all
about. That's beyond our scope here but we'll come back to it in the next
tutorial when we start looking at concurrency options.
- */
-class Client_Handler : public ACE_Svc_Handler < ACE_SOCK_STREAM, ACE_NULL_SYNCH >
+ */</font>
+class Client_Handler : public ACE_Svc_Handler &lt; ACE_SOCK_STREAM, ACE_NULL_SYNCH >
{
public:
- // Constructor...
+ <font color=red>// Constructor...</font>
Client_Handler (void);
- /*
+ <font color=red>/*
The destroy() method is our preferred method of destruction. We could
have overloaded the delete operator but that is neither easy nor
intuitive (at least to me). Instead, we provide a new method of
destruction and we make our destructor protected so that only ourselves,
our derivatives and our friends can delete us. It's a nice
compromise.
- */
+ */</font>
void destroy (void);
- /*
+ <font color=red>/*
Most ACE objects have an open() method. That's how you make them ready
to do work. ACE_Event_Handler has a virtual open() method which allows us
- to create this overrride. ACE_Acceptor<> will invoke this method after
+ to create this overrride. ACE_Acceptor&lt;> will invoke this method after
creating a new Client_Handler when a client connects. Notice that the
parameter to open() is a void*. It just so happens that the pointer
points to the acceptor which created us. You would like for the parameter
- to be an ACE_Acceptor<>* but since ACE_Event_Handler is generic, that
- would tie it too closely to the ACE_Acceptor<> set of objects. In our
+ to be an ACE_Acceptor&lt;>* but since ACE_Event_Handler is generic, that
+ would tie it too closely to the ACE_Acceptor&lt;> set of objects. In our
definition of open() you'll see how we get around that.
- */
+ */</font>
int open (void *_acceptor);
- /*
+ <font color=red>/*
When there is activity on a registered handler, the handle_input() method
of the handler will be invoked. If that method returns an error code (eg
-- -1) then the reactor will invoke handle_close() to allow the object to
@@ -99,47 +102,43 @@ public:
As a side-effect, the reactor will also invoke remove_handler()
for the object on the mask that caused the -1 return. This means
that we don't have to do that ourselves!
- */
+ */</font>
int handle_close (ACE_HANDLE _handle, ACE_Reactor_Mask _mask);
protected:
- /*
+ <font color=red>/*
When we register with the reactor, we're going to tell it that we want to
be notified of READ events. When the reactor sees that there is read
activity for us, our handle_input() will be invoked. The _handleg
provided is the handle (file descriptor in Unix) of the actual connection
- causing the activity. Since we're derived from ACE_Svc_Handler<> and it
+ causing the activity. Since we're derived from ACE_Svc_Handler&lt;> and it
maintains it's own peer (ACE_SOCK_Stream) object, this is redundant for
us. However, if we had been derived directly from ACE_Event_Handler, we
may have chosen not to contain the peer. In that case, the _handleg
would be important to us for reading the client's data.
- */
+ */</font>
int handle_input (ACE_HANDLE _handle);
- /*
+ <font color=red>/*
This has nothing at all to do with ACE. I've added this here as a worker
function which I will call from handle_input(). That allows me to
introduce concurrencly in later tutorials with a no changes to the worker
function. You can think of process() as application-level code and
everything else as application-framework code.
- */
+ */</font>
int process (char *_rdbuf, int _rdbuf_len);
- /*
+ <font color=red>/*
We don't really do anything in our destructor but we've declared it to be
protected to prevent casual deletion of this object. As I said above, I
really would prefer that everyone goes through the destroy() method to get
rid of us.
- */
+ */</font>
~Client_Handler (void);
};
-#endif // CLIENT_HANDLER_H
-</pre>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page05.html">Continue This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<font color=blue>#endif</font> <font color=red>// CLIENT_HANDLER_H</font>
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page05.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page05.html b/docs/tutorials/005/page05.html
index d9126ecbc81..029683a7ca1 100644
--- a/docs/tutorials/005/page05.html
+++ b/docs/tutorials/005/page05.html
@@ -22,9 +22,11 @@ rest of the application all together.
<P>
<HR WIDTH="100%">
-<pre>
-<FONT FACE="Arial,Helvetica">
-/*
+<PRE>
+
+<font color=red>// $Id$</font>
+
+<font color=red>/*
In client_handler.h I alluded to the fact that we'll mess around with a
Client_Acceptor pointer. To do so, we need the Client_Acceptor object
declaration.
@@ -35,109 +37,109 @@ rest of the application all together.
we're using.
On the other hand, we don't directly include any ACE header files here.
- */
-#include "client_acceptor.h"
-#include "client_handler.h"
+ */</font>
+<font color=blue>#include</font> "<font color=green>client_acceptor.h</font>"
+<font color=blue>#include</font> "<font color=green>client_handler.h</font>"
-/*
+<font color=red>/*
Our constructor doesn't do anything. That's generally a good idea. Unless
you want to start throwing exceptions, there isn't a really good way to
indicate that a constructor has failed. If I had my way, I'd have a boolean
return code from it that would cause new to return 0 if I failed. Oh
well...
- */
-Client_Handler::Client_Handler (void)
+ */</font>
+<font color=#008888>Client_Handler::Client_Handler</font> (void)
{
}
-/*
+<font color=red>/*
Our destructor doesn't do anything either. That is also by design.
Remember, we really want folks to use destroy() to get rid of us. If that's
so, then there's nothing left to do when the destructor gets invoked.
- */
-Client_Handler::~Client_Handler (void)
+ */</font>
+<font color=#008888>Client_Handler::~Client_Handler</font> (void)
{
- // Make sure that our peer closes when we're deleted. This
- // will probably happend when the peer is deleted but it
- // doesn't hurt to be explicit.
+ <font color=red>// Make sure that our peer closes when we're deleted. This</font>
+ <font color=red>// will probably happend when the peer is deleted but it</font>
+ <font color=red>// doesn't hurt to be explicit.</font>
this->peer ().close ();
}
-/*
+<font color=red>/*
The much talked about destroy() method! The reason I keep going on about
this is because it's just a Bad Idea (TM) to do real work inside of a
destructor. Although this method is void, it really should return
int so that it can tell the caller there was a problem. Even as
void you could at least throw an exception which you would never want
to do in a destructor.
- */
-void Client_Handler::destroy (void)
+ */</font>
+void <font color=#008888>Client_Handler::destroy</font> (void)
{
- /*
+ <font color=red>/*
Tell the reactor to forget all about us. Notice that we use the same args
here that we use in the open() method to register ourselves. In addition,
we use the DONT_CALL flag to prevent handle_close() being called. Since we
likely got here due to handle_close(), that could cause a bit of nasty
recursion!
- */
+ */</font>
this->reactor ()->remove_handler (this,
- ACE_Event_Handler:: READ_MASK | ACE_Event_Handler::DONT_CALL);
+ ACE_Event_Handler:: READ_MASK | <font color=#008888>ACE_Event_Handler::DONT_CALL</font>);
- /*
+ <font color=red>/*
This is how we're able to tell folks not to use delete. By
deleting our own instance, we take care of memory leaks after ensuring
that the object is shut down correctly.
- */
+ */</font>
delete this;
}
-/*
+<font color=red>/*
As mentioned before, the open() method is called by the Client_Acceptor when
a new client connection has been accepted. The Client_Acceptor instance
pointer is cast to a void* and given to us here. We'll use that to avoid
some global data...
- */
-int Client_Handler::open (void *_acceptor)
+ */</font>
+int <font color=#008888>Client_Handler::open</font> (void *_acceptor)
{
- /*
+ <font color=red>/*
Convert the void* to a Client_Acceptor*. You should probably use those
fancy new C++ cast operators but I can never remember how/when to do so.
Since you can cast just about anything around a void* without compiler
warnings be very sure of what you're doing when you do this kind of thing.
That's where the new-style cast operators can save you.
- */
+ */</font>
Client_Acceptor *acceptor = (Client_Acceptor *) _acceptor;
- /*
+ <font color=red>/*
Our reactor reference will be set when we register ourselves but I decided
to go ahead and set it here. No good reason really...
- */
+ */</font>
this->reactor (acceptor->reactor ());
- /*
+ <font color=red>/*
We need this to store the address of the client that we are now connected
to. We'll use it later to display a debug message.
- */
+ */</font>
ACE_INET_Addr addr;
- /*
+ <font color=red>/*
Our ACE_Svc_Handler baseclass gives us the peer() method as a way to
access our underlying ACE_SOCK_Stream. On that object, we can invoke the
- get_remote_addr() method to get an ACE_INET_Addr having our client's
+ get_remote_addr() method to get get an ACE_INET_Addr having our client's
address information. As with most ACE methods, we'll get back (and return)
a -1 if there was any kind of error. Once we have the ACE_INET_Addr, we
- can query it to find out the client's host name, TCP/IP address, TCP/IP
+ can query it to find out the clien's host name, TCP/IP address, TCP/IP
port value and so forth. One word of warning: the get_host_name()
- method of ACE_INET_Addr may return an empty string if your name server
+ method of ACE_INET_Addr may return you an empty string if your name server
can't resolve it. On the other hand, get_host_addr() will always give you
the dotted-decimal string representing the TCP/IP address.
- */
+ */</font>
if (this->peer ().get_remote_addr (addr) == -1)
{
return -1;
}
- /*
+ <font color=red>/*
If we managed to get the client's address then we're connected to a real
and valid client. I suppose that in some cases, the client may connect
and disconnect so quickly that it is invalid by the time we get here. In
@@ -149,68 +151,68 @@ int Client_Handler::open (void *_acceptor)
reactor value from the acceptor which created us in the first place.
Since we're exploring a single-threaded implementation, this is the
correct thing to do.
- */
- if (this->reactor ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1)
+ */</font>
+ if (this->reactor ()->register_handler (this, <font color=#008888>ACE_Event_Handler::READ_MASK</font>) == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) can't register with reactor\n</font>"), -1);
}
- /*
+ <font color=red>/*
Here, we use the ACE_INET_Addr object to print a message with the name of
the client we're connected to. Again, it is possible that you'll get an
empty string for the host name if your DNS isn't configured correctly or
if there is some other reason that a TCP/IP addreess cannot be converted
into a host name.
- */
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", addr.get_host_name ()));
+ */</font>
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) connected with %s\n</font>", addr.get_host_name ()));
- /*
+ <font color=red>/*
Always return zero on success.
- */
+ */</font>
return 0;
}
-/*
+<font color=red>/*
In the open() method, we registered with the reactor and requested to be
notified when there is data to be read. When the reactor sees that activity
it will invoke this handle_input() method on us. As I mentioned, the _handle
parameter isn't useful to us but it narrows the list of methods the reactor
has to worry about and the list of possible virtual functions we would have
to override.
- */
-int Client_Handler::handle_input (ACE_HANDLE _handle)
+ */</font>
+int <font color=#008888>Client_Handler::handle_input</font> (ACE_HANDLE _handle)
{
- /*
+ <font color=red>/*
Some compilers don't like it when you fail to use a parameter. This macro
will keep 'em quiet for you.
- */
+ */</font>
ACE_UNUSED_ARG (_handle);
- /*
+ <font color=red>/*
Now, we create and initialize a buffer for receiving the data. Since this
is just a simple test app, we'll use a small buffer size.
- */
+ */</font>
char buf[128];
- ACE_OS::memset (buf, 0, sizeof (buf));
+ <font color=#008888>ACE_OS::memset</font> (buf, 0, sizeof (buf));
- /*
+ <font color=red>/*
Invoke the process() method with a pointer to our data area. We'll let
that method worry about interfacing with the data. You might choose to go
ahead and read the data and then pass the result to process(). However,
application logic may require that you read a few bytes to determine what
else to read... It's best if we push that all into the application-logic
level.
- */
+ */</font>
return this->process (buf, sizeof (buf));
}
-/*
+<font color=red>/*
If we return -1 out of handle_input() or if the reactor sees other problems
with us then handle_close() will be called. The reactor framework
will take care of removing us (due to the -1), so we don't need to
use the destroy() method. Instead, we just delete ourselves directly.
- */
-int Client_Handler::handle_close (ACE_HANDLE _handle, ACE_Reactor_Mask _mask)
+ */</font>
+int <font color=#008888>Client_Handler::handle_close</font> (ACE_HANDLE _handle, ACE_Reactor_Mask _mask)
{
ACE_UNUSED_ARG (_handle);
ACE_UNUSED_ARG (_mask);
@@ -219,17 +221,17 @@ int Client_Handler::handle_close (ACE_HANDLE _handle, ACE_Reactor_Mask _mask)
return 0;
}
-/*
+<font color=red>/*
And, at last, we get to the application-logic level. Out of everything
we've done so far, this is the only thing that really has anything to do
with what your application will do. In this method we will read and process
the client's data. In a real appliation, you will probably have a bit more
in main() to deal with command line options but after that point, all of the
action takes place here.
- */
-int Client_Handler::process (char *_rdbuf, int _rdbuf_len)
+ */</font>
+int <font color=#008888>Client_Handler::process</font> (char *_rdbuf, int _rdbuf_len)
{
- /*
+ <font color=red>/*
Using the buffer provided for us, we read the data from the client. If
there is a read error (eg -- recv() returns -1) then it's a pretty good
bet that the connection is gone. Likewise, if we read zero bytes then
@@ -239,30 +241,19 @@ int Client_Handler::process (char *_rdbuf, int _rdbuf_len)
On the other hand, if we got some data then we can display it in a debug
message for everyone to see.
- */
+ */</font>
switch (this->peer ().recv (_rdbuf, _rdbuf_len))
{
case -1:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p bad read\n", "client"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) %p bad read\n</font>", "<font color=green>client</font>"), -1);
case 0:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing daemon (fd = %d)\n", this->get_handle ()), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) closing daemon (fd = %d)\n</font>", this->get_handle ()), -1);
default:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) from client: %s", _rdbuf));
+ ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) from client: %s</font>", _rdbuf));
}
return 0;
}
-</pre>
-<HR WIDTH="100%">
-
-<P>That's the last of the C++&nbsp;code.&nbsp; On the final two pages I'll
-go over the Makefile and a short perl script I wrote to "assist"&nbsp;the
-Makefile.&nbsp; Please... Continue...
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page06.html">Continue This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page06.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page06.html b/docs/tutorials/005/page06.html
index 95a341cf0ea..76c545e5cf8 100644
--- a/docs/tutorials/005/page06.html
+++ b/docs/tutorials/005/page06.html
@@ -20,176 +20,118 @@
<P>
<HR WIDTH="100%">
-<BR>&nbsp;
-<UL><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-<BR><FONT FACE="Arial,Helvetica">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-$Id$</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-
-<P><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-<BR><FONT FACE="Arial,Helvetica">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-Local macros</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-
-<P><FONT FACE="Arial,Helvetica"># You can generally find a Makefile in
-the ACE examples, tests or the library</FONT>
-<BR><FONT FACE="Arial,Helvetica"># itself that will satisfy our application
-needs.&nbsp; This one was taken from</FONT>
-<BR><FONT FACE="Arial,Helvetica"># one of the examples.</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Define the name of the binary we want to create.&nbsp; There has to be</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# a CPP file $(BIN).cpp but it doesn't necessarily have to have your</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# main() in it.&nbsp; Most of the time, though, it will.</FONT>
-<BR><FONT FACE="Arial,Helvetica">BIN&nbsp;&nbsp;&nbsp; = server</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Few applications will have a single source file.&nbsp; We use the FILES</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# macro to build up a list of additional files to compile.&nbsp; Notice</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# that we leave off the extension just as with BIN</FONT>
-<BR><FONT FACE="Arial,Helvetica">FILES&nbsp; =</FONT>
-<BR><FONT FACE="Arial,Helvetica">FILES += client_handler</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# The BUILD macro is used by the ACE makefiles.&nbsp; Basically, it tells</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# the system what to build.&nbsp; I don't really know what VBIN is other</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# than it is constructed from the value of BIN.&nbsp; Just go with it...</FONT>
-<BR><FONT FACE="Arial,Helvetica">BUILD&nbsp;&nbsp; = $(VBIN)</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Here we use some GNU make extensions to build the SRC macro. Basically,</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# we're just adding .cpp to the value of BIN and for each entry of the</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# FILES macro.</FONT>
-<BR><FONT FACE="Arial,Helvetica">SRC = $(addsuffix .cpp,$(BIN)) $(addsuffix
-.cpp,$(FILES))</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# This is used by my Indent target below.&nbsp; It's not a part of standard</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# ACE and you don't need it yourself.</FONT>
-<BR><FONT FACE="Arial,Helvetica">HDR = *.h</FONT>
-
-<P><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-<BR><FONT FACE="Arial,Helvetica">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-Include macros and targets</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# This is where the real power lies!&nbsp; These included makefile components</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# are similar to the C++ templates in ACE.&nbsp; That is, they do a tremendous</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# amount of work for you and all you have to do is include them.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# As a matter of fact, in our project, I created a single file named</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# "app.mk" that includes all of these.&nbsp; Our project makefiles then
-just</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# need to include app.mk to get everything they need.</FONT>
-
-<P><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/macros.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/rules.common.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU</FONT>
-<BR><FONT FACE="Arial,Helvetica">include $(ACE_ROOT)/include/makeinclude/rules.local.GNU</FONT>
-
-<P><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-<BR><FONT FACE="Arial,Helvetica">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-Local targets</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Sometimes I like to reformat my code to make it more readable.&nbsp;
-This is</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# more useful for the comments than anything else.&nbsp; Unfortunately,
-the</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# "indent" program doesn't quite grok C++ so I have to post-process it's</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# output just a bit.</FONT>
-<BR><FONT FACE="Arial,Helvetica">Indent : #</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-for i in $(SRC) $(HDR) ; do \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-indent -npsl -l80 -fca -fc1 -cli0 -cdb &lt; $$i | \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-sed -e 's/: :/::/g'&nbsp; \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/^.*\(public:\)/\1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/^.*\(protected:\)/\1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/^.*\(private:\)/\1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/:\(public\)/ : \1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/:\(protected\)/ : \1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--e 's/:\(private\)/ : \1/' \</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-> $$i~ ;\</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-mv $$i~ $$i ;\</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-done</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# One of the targets in the ACE makefiles is "depend".&nbsp; It will invoke</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# your compiler in a way that will generate a list of dependencies for</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# you.&nbsp; This is a great thing!&nbsp; Unfortunately, it puts all of
-that mess</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# directly into the Makefile.&nbsp; I prefer my Makefile to stay clean
-and</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# uncluttered.&nbsp; The perl script referenced here pulls the dependency</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# stuff back out of the Makefile and into a file ".depend" which we then</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# include just like the makefile components above.</FONT>
-<BR><FONT FACE="Arial,Helvetica">Depend : depend</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-perl fix.Makefile</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-<BR><FONT FACE="Arial,Helvetica">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-Dependencies</FONT>
-<BR><FONT FACE="Arial,Helvetica">#----------------------------------------------------------------------------</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Don't put anything below here.&nbsp; Between the "depend" target and
-fix.Makefile</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# it's guaranteed to be lost!</FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# This is inserted by the fix.Makefile script</FONT>
-<BR><FONT FACE="Arial,Helvetica">include .depend</FONT></UL>
-
-<HR WIDTH="100%">
-
-<P>Remember, make wants to see tabs leading all of the directives.&nbsp;
-If you do a cut/paste job you'll need to convert all leading spaces to
-tabs or make will be very unhappy with you.
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page07.html">Continue This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<PRE>
+#----------------------------------------------------------------------------
+# $Id$
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+# You can generally find a Makefile in the ACE examples, tests or the library
+# itself that will satisfy our application needs. This one was taken from
+# one of the examples.
+
+ # Define the name of the binary we want to create. There has to be
+ # a CPP file $(BIN).cpp but it doesn't necessarily have to have your
+ # main() in it. Most of the time, though, it will.
+BIN = server
+
+ # Few applications will have a single source file. We use the FILES
+ # macro to build up a list of additional files to compile. Notice
+ # that we leave off the extension just as with BIN
+FILES =
+FILES += client_handler
+
+ # The BUILD macro is used by the ACE makefiles. Basically, it tells
+ # the system what to build. I don't really know what VBIN is other
+ # than it is constructed from the value of BIN. Just go with it...
+BUILD = $(VBIN)
+
+ # Here we use some GNU make extensions to build the SRC macro. Basically,
+ # we're just adding .cpp to the value of BIN and for each entry of the
+ # FILES macro.
+SRC = $(addsuffix .cpp,$(BIN)) $(addsuffix .cpp,$(FILES))
+
+ # This is used by my Indent target below. It's not a part of standard
+ # ACE and you don't need it yourself.
+HDR = *.h
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+ # This is where the real power lies! These included makefile components
+ # are similar to the C++ templates in ACE. That is, they do a tremendous
+ # amount of work for you and all you have to do is include them.
+ # As a matter of fact, in our project, I created a single file named
+ # "<font color=green>app.mk</font>" that includes all of these. Our project makefiles then just
+ # need to include app.mk to get everything they need.
+
+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
+#----------------------------------------------------------------------------
+
+ # Sometimes I like to reformat my code to make it more readable. This is
+ # more useful for the comments than anything else. Unfortunately, the
+ # "<font color=green>indent</font>" program doesn't quite grok C++ so I have to post-process it's
+ # output just a bit.
+Indent : #
+ for i in $(SRC) $(HDR) ; do \
+ indent -npsl -l80 -fca -fc1 -cli0 -cdb &lt; $$i | \
+ sed -e 's/: :/::/g' \
+ -e 's/^.*\(public:\)/\1/' \
+ -e 's/^.*\(protected:\)/\1/' \
+ -e 's/^.*\(private:\)/\1/' \
+ -e 's/:\(public\)/ : \1/' \
+ -e 's/:\(protected\)/ : \1/' \
+ -e 's/:\(private\)/ : \1/' \
+ > $$i~ ;\
+ mv $$i~ $$i ;\
+ done
+
+ # One of the targets in the ACE makefiles is "<font color=green>depend</font>". It will invoke
+ # your compiler in a way that will generate a list of dependencies for
+ # you. This is a great thing! Unfortunately, it puts all of that mess
+ # directly into the Makefile. I prefer my Makefile to stay clean and
+ # uncluttered. The perl script referenced here pulls the dependency
+ # stuff back out of the Makefile and into a file "<font color=green>.depend</font>" which we then
+ # include just like the makefile components above.
+Depend : depend
+ perl ../fix.Makefile
+
+.depend : #
+ touch .depend
+
+
+HTML : #
+ [ -f hdr ] || $(MAKE) UNSHAR
+ perl ../combine *.pre ; chmod +r *.html
+
+SHAR : #
+ [ ! -f combine.shar ] || exit 1
+ shar -T hdr bodies *.pre > combine.shar && rm -f hdr bodies *.pre *.pst
+
+UNSHAR : #
+ sh combine.shar
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+
+ # Don't put anything below here. Between the "<font color=green>depend</font>" target and fix.Makefile
+ # it's guaranteed to be lost!
+
+ # This is inserted by the fix.Makefile script
+include .depend
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page07.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page07.html b/docs/tutorials/005/page07.html
index 069f94be956..3a7433dbd34 100644
--- a/docs/tutorials/005/page07.html
+++ b/docs/tutorials/005/page07.html
@@ -16,108 +16,80 @@
<P>
<HR WIDTH="100%">
-<P>And last (and probably least) is the <A HREF="fix.Makefile">perl script</A>
+<P>And last (and probably least) is the <A HREF="../fix.Makefile">perl script</A>
that pulls the dependency stuff out of Makefile and into .depend.
<P>
<HR WIDTH="100%">
-<BR>&nbsp; <FONT FACE="Arial,Helvetica">#!/usr/bin/perl</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Open the Makefile that has been mangled by 'make depend'</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# and suck it into a perl array.</FONT>
-<BR><FONT FACE="Arial,Helvetica">open(IF,"&lt;Makefile") || die;</FONT>
-<BR><FONT FACE="Arial,Helvetica">@makefile = &lt;IF>;</FONT>
-<BR><FONT FACE="Arial,Helvetica">close(IF);</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Now open our .depend file and a temporary Makefile.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# We'll split the original Makefile between these two.</FONT>
-<BR><FONT FACE="Arial,Helvetica">open(DF,">.depend") || die;</FONT>
-<BR><FONT FACE="Arial,Helvetica">open(MF,">Makefile.tmp") || die;</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# For each line we read out of the original file...</FONT>
-<BR><FONT FACE="Arial,Helvetica">foreach (@makefile) {</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# If we're into the dependency section, write the line</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# into the .depend file.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-#</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-if( $depend ) {</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-print DF $_;</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-}</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-else {</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# If we haven't gotten to the dependency section yet</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# then see if the current line is the separator that</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# "make depend" causes to be inserted.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-#</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# If so, change our "mode" and skip this line.</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-++$depend;</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-next;</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-}</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Also skip the "include .depend" that we insert.&nbsp; If we</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# don't do this, it is possible to have a bunch of these</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# inserted into the output when we read an unmangled Makefile</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-next if( m/^include .depend/ );</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-# Print the non-dependency info to the temporary Makefile</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-print MF $_;</FONT>
-<BR><FONT FACE="Arial,Helvetica">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-}</FONT>
-<BR><FONT FACE="Arial,Helvetica">}</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica"># Tell our new Makefile to include the
-dependency file</FONT>
-<BR><FONT FACE="Arial,Helvetica">print MF "include .depend\n";</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica"># Close the two output files...</FONT>
-<BR><FONT FACE="Arial,Helvetica">close(DF);</FONT>
-<BR><FONT FACE="Arial,Helvetica">close(MF);</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica"># Unlink (remove) the original Makefile
-and rename our</FONT>
-<BR><FONT FACE="Arial,Helvetica"># temporary file.&nbsp; There's obviously
-room for error checking</FONT>
-<BR><FONT FACE="Arial,Helvetica"># here but we've got the Makefile checked
-into some revision</FONT>
-<BR><FONT FACE="Arial,Helvetica"># control system anyway.&nbsp; Don't we?</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">unlink("Makefile");</FONT>
-<BR><FONT FACE="Arial,Helvetica">rename("Makefile.tmp","Makefile");</FONT><FONT FACE="Arial,Helvetica"></FONT>
-
-<P><FONT FACE="Arial,Helvetica">exit(0);</FONT>
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>] [<A HREF="page08.html">Continue This Tutorial</A>]</CENTER>
-
-</BODY>
-</HTML>
+<PRE>
+eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"<font color=green>$@</font>"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+require "<font color=green>getopts.pl</font>";
+&Getopts("<font color=green>f:o:</font>");
+
+$opt_f = "<font color=green>Makefile</font>" if( ! $opt_f );
+$opt_o = "<font color=green>.depend</font>" if( ! $opt_o );
+
+ # Open the Makefile that has been mangled by 'make depend'
+ # and suck it into a perl array.
+open(IF,"<font color=green>&lt;$opt_f</font>") || die;
+@makefile = &lt;IF>;
+close(IF);
+
+ # Now open our .depend file and a temporary Makefile.
+ # We'll split the original Makefile between these two.
+open(DF,"<font color=green>>$opt_o</font>") || die;
+open(MF,"<font color=green>>$opt_f.tmp</font>") || die;
+
+ # For each line we read out of the original file...
+foreach (@makefile) {
+
+ # If we're into the dependency section, write the line
+ # into the .depend file.
+ #
+ if( $depend ) {
+ print DF $_;
+ }
+ else {
+ # If we haven't gotten to the dependency section yet
+ # then see if the current line is the separator that
+ # "<font color=green>make depend</font>" causes to be inserted.
+ #
+ if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {
+
+ # If so, change our "<font color=green>mode</font>" and skip this line.
+ ++$depend;
+ next;
+ }
+
+ # Also skip the "<font color=green>include .depend</font>" that we insert. If we
+ # don't do this, it is possible to have a bunch of these
+ # inserted into the output when we read an unmangled Makefile
+ next if( m/^include $opt_o/ );
+
+ # Print the non-dependency info to the temporary Makefile
+ print MF $_;
+ }
+}
+
+# Tell our new Makefile to include the dependency file
+print MF "<font color=green>include $opt_o\n</font>";
+
+# Close the two output files...
+close(DF);
+close(MF);
+
+# Unlink (remove) the original Makefile and rename our
+# temporary file. There's obviously room for error checking
+# here but we've got the Makefile checked into some revision
+# control system anyway. Don't we?
+
+unlink("<font color=green>$opt_f</font>");
+rename("<font color=green>$opt_f.tmp</font>","<font color=green>$opt_f</font>");
+
+exit(0);
+</PRE>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page08.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/005/page08.html b/docs/tutorials/005/page08.html
index 6cc18602049..db7acc3f76b 100644
--- a/docs/tutorials/005/page08.html
+++ b/docs/tutorials/005/page08.html
@@ -40,14 +40,8 @@ and thread pool.
<A HREF="server.cpp">server.cpp</A></LI>
<LI>
-<A HREF="fix.Makefile">fix.Makefile</A></LI>
+<A HREF="../fix.Makefile">fix.Makefile</A></LI>
</UL>
&nbsp;
-
-<P>
-<HR WIDTH="100%">
-<CENTER>[<A HREF="..">Tutorial
-Index</A>]</CENTER>
-
-</BODY>
-</HTML>
+<P><HR WIDTH="100%">
+<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/006/fix.Makefile b/docs/tutorials/006/fix.Makefile
deleted file mode 100644
index e99c194114a..00000000000
--- a/docs/tutorials/006/fix.Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/perl
-
- # Open the Makefile that has been mangled by 'make depend'
- # and suck it into a perl array.
-open(IF,"<Makefile") || die;
-@makefile = <IF>;
-close(IF);
-
- # Now open our .depend file and a temporary Makefile.
- # We'll split the original Makefile between these two.
-open(DF,">.depend") || die;
-open(MF,">Makefile.tmp") || die;
-
- # For each line we read out of the original file...
-foreach (@makefile) {
-
- # If we're into the dependency section, write the line
- # into the .depend file.
- #
- if( $depend ) {
- print DF $_;
- }
- else {
- # If we haven't gotten to the dependency section yet
- # then see if the current line is the separator that
- # "make depend" causes to be inserted.
- #
- if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {
-
- # If so, change our "mode" and skip this line.
- ++$depend;
- next;
- }
-
- # Also skip the "include .depend" that we insert. If we
- # don't do this, it is possible to have a bunch of these
- # inserted into the output when we read an unmangled Makefile
- next if( m/^include .depend/ );
-
- # Print the non-dependency info to the temporary Makefile
- print MF $_;
- }
-}
-
-# Tell our new Makefile to include the dependency file
-print MF "include .depend\n";
-
-# Close the two output files...
-close(DF);
-close(MF);
-
-# Unlink (remove) the original Makefile and rename our
-# temporary file. There's obviously room for error checking
-# here but we've got the Makefile checked into some revision
-# control system anyway. Don't we?
-
-unlink("Makefile");
-rename("Makefile.tmp","Makefile");
-
-exit(0);
diff --git a/docs/tutorials/007/fix.Makefile b/docs/tutorials/007/fix.Makefile
deleted file mode 100755
index e99c194114a..00000000000
--- a/docs/tutorials/007/fix.Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/perl
-
- # Open the Makefile that has been mangled by 'make depend'
- # and suck it into a perl array.
-open(IF,"<Makefile") || die;
-@makefile = <IF>;
-close(IF);
-
- # Now open our .depend file and a temporary Makefile.
- # We'll split the original Makefile between these two.
-open(DF,">.depend") || die;
-open(MF,">Makefile.tmp") || die;
-
- # For each line we read out of the original file...
-foreach (@makefile) {
-
- # If we're into the dependency section, write the line
- # into the .depend file.
- #
- if( $depend ) {
- print DF $_;
- }
- else {
- # If we haven't gotten to the dependency section yet
- # then see if the current line is the separator that
- # "make depend" causes to be inserted.
- #
- if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {
-
- # If so, change our "mode" and skip this line.
- ++$depend;
- next;
- }
-
- # Also skip the "include .depend" that we insert. If we
- # don't do this, it is possible to have a bunch of these
- # inserted into the output when we read an unmangled Makefile
- next if( m/^include .depend/ );
-
- # Print the non-dependency info to the temporary Makefile
- print MF $_;
- }
-}
-
-# Tell our new Makefile to include the dependency file
-print MF "include .depend\n";
-
-# Close the two output files...
-close(DF);
-close(MF);
-
-# Unlink (remove) the original Makefile and rename our
-# temporary file. There's obviously room for error checking
-# here but we've got the Makefile checked into some revision
-# control system anyway. Don't we?
-
-unlink("Makefile");
-rename("Makefile.tmp","Makefile");
-
-exit(0);
diff --git a/docs/tutorials/010/Makefile b/docs/tutorials/010/Makefile
index d52722d4994..683e82cbcda 100644
--- a/docs/tutorials/010/Makefile
+++ b/docs/tutorials/010/Makefile
@@ -47,7 +47,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
diff --git a/docs/tutorials/011/Makefile b/docs/tutorials/011/Makefile
index d52722d4994..683e82cbcda 100644
--- a/docs/tutorials/011/Makefile
+++ b/docs/tutorials/011/Makefile
@@ -47,7 +47,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
diff --git a/docs/tutorials/012/Makefile b/docs/tutorials/012/Makefile
index d52722d4994..683e82cbcda 100644
--- a/docs/tutorials/012/Makefile
+++ b/docs/tutorials/012/Makefile
@@ -47,7 +47,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
diff --git a/docs/tutorials/013/Makefile b/docs/tutorials/013/Makefile
index eaa5766926e..af3b091d67e 100644
--- a/docs/tutorials/013/Makefile
+++ b/docs/tutorials/013/Makefile
@@ -47,7 +47,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
HTML : #
[ -f hdr ] || $(MAKE) UNSHAR
diff --git a/docs/tutorials/014/Makefile b/docs/tutorials/014/Makefile
index 42e20ef079f..165e7bb0039 100644
--- a/docs/tutorials/014/Makefile
+++ b/docs/tutorials/014/Makefile
@@ -51,7 +51,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
diff --git a/docs/tutorials/016/Makefile b/docs/tutorials/016/Makefile
index 65ce0bb1352..bd1cb8a6bd0 100644
--- a/docs/tutorials/016/Makefile
+++ b/docs/tutorials/016/Makefile
@@ -51,7 +51,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend
diff --git a/docs/tutorials/017/Makefile b/docs/tutorials/017/Makefile
index 0830f114d68..5703100210c 100644
--- a/docs/tutorials/017/Makefile
+++ b/docs/tutorials/017/Makefile
@@ -51,7 +51,7 @@ Indent : #
done
Depend : depend
- perl ../007/fix.Makefile
+ perl ../fix.Makefile
.depend : #
touch .depend