diff options
Diffstat (limited to 'docs/tutorials/015/page16.html')
-rw-r--r-- | docs/tutorials/015/page16.html | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/docs/tutorials/015/page16.html b/docs/tutorials/015/page16.html deleted file mode 100644 index 023fd224ee0..00000000000 --- a/docs/tutorials/015/page16.html +++ /dev/null @@ -1,91 +0,0 @@ -<!-- $Id$ --> -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="James CE Johnson"> - <TITLE>ACE Tutorial 015</TITLE> -</HEAD> -<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F"> - -<CENTER><B><FONT SIZE=+2>ACE Tutorial 015</FONT></B></CENTER> - -<CENTER><B><FONT SIZE=+2>Building a protocol stream</FONT></B></CENTER> - -<P> -<HR WIDTH="100%"> -Recv is the sibling to Xmit. Again, they could be combined into a -single object if you want. -<P> -An ACE_Stream is designed to handle downstream traffic very -well. You put() data into it and it flows along towards the tail. -However, there doesn't seem to be a way to put data in such that it -will travel upstream. To get around that, I've added a get() method -to Recv that will trigger a read on the socket. Recv will then put -the data to the next upstream module and we're on our way. As noted -earlier, that data will eventually show up either in the <i>reader</i> -(if installed on the stream open()) or the stream head reader task's -message queue. -<HR> -<PRE> -<font color=red>// $Id$</font> - -<font color=blue>#ifndef</font> <font color=purple>RECV_H</font> -<font color=blue>#define</font> <font color=purple>RECV_h</font> - -<font color=blue>#include</font> "<font color=green>Protocol_Task.h</font>" - -class ACE_SOCK_Stream; - -<font color=red>/* Get some data from the peer and send it upstream for - de-protocol-ization. -*/</font> -class Recv : public Protocol_Task -{ -public: - typedef Protocol_Task inherited; - - <font color=red>// Give it someone to talk to...</font> - Recv (ACE_SOCK_Stream &peer); - ~Recv (void); - - <font color=red>// Trigger a read from the socket</font> - int get (void); - - <font color=red>// In some cases it might be easier to check the "<font color=green>state</font>" of the Recv</font> - <font color=red>// object than to rely on return codes filtering back to you.</font> - int error (void) - { - return this->error_; - } - -protected: - - ACE_SOCK_Stream &peer (void) - { - return this->peer_; - } - - <font color=red>// The baseclass will trigger this when our get() method is called.</font> - <font color=red>// A message block of the appropriate size is created, filled and</font> - <font color=red>// passed up the stream.</font> - int recv (ACE_Message_Block *message, - ACE_Time_Value *timeout = 0); - -private: - <font color=red>// Our endpoint</font> - ACE_SOCK_Stream &peer_; - - <font color=red>// get() uses a bogus message block to cause the baseclass to invoke</font> - <font color=red>// recv(). To avoid memory thrashing, we create that bogus message</font> - <font color=red>// once and reuse it for the life of Recv.</font> - ACE_Message_Block *tickler_; - - <font color=red>// Our error flag (duh)</font> - int error_; -}; - -<font color=blue>#endif</font> <font color=red>/* RECV_H */</font> -</PRE> -<P><HR WIDTH="100%"> -<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page17.html">Continue This Tutorial</A>]</CENTER> - |