summaryrefslogtreecommitdiff
path: root/docs/tutorials/Chap_6/ex05.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/Chap_6/ex05.html')
-rw-r--r--docs/tutorials/Chap_6/ex05.html129
1 files changed, 0 insertions, 129 deletions
diff --git a/docs/tutorials/Chap_6/ex05.html b/docs/tutorials/Chap_6/ex05.html
deleted file mode 100644
index c983e5751f9..00000000000
--- a/docs/tutorials/Chap_6/ex05.html
+++ /dev/null
@@ -1,129 +0,0 @@
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="Ambreen Ilyas">
- <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]">
- <TITLE>Example 5</TITLE>
-</HEAD>
-<BODY>
-<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT>
-<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers
-Guide.</FONT>
-<BR><FONT COLOR="#CC0000">////&nbsp; Chapter:&nbsp; "The Acceptor/Connector"&nbsp;
-(Connection Initialization)</FONT>
-<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT>
-<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT>
-<BR><FONT COLOR="#CC0000">////&nbsp; AUTHOR: Umar Syyid (usyyid@hns.com)</FONT>
-<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT>
-<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT>
-
-<P><FONT COLOR="#CC0000">//Example 5</FONT>
-<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Reactor.h"</FONT>
-<BR><FONT COLOR="#000099">#include</FONT> "<FONT COLOR="#006600">ace/Svc_Handler.h"</FONT>
-<BR><FONT COLOR="#000099">#include</FONT> "<FONT COLOR="#006600">ace/Acceptor.h"</FONT>
-<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Synch.h"</FONT>
-<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/SOCK_Acceptor.h"</FONT>
-<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/Thread.h"</FONT>
-
-<P><FONT COLOR="#FF0000">//Add our own Reactor singleton</FONT>
-<BR>typedef ACE_Singleton&lt;ACE_Reactor,ACE_Null_Mutex> Reactor;
-<BR><FONT COLOR="#FF0000">//Create an Acceptor</FONT>
-<BR>typedef ACE_Acceptor&lt;MyServiceHandler,ACE_SOCK_ACCEPTOR> Acceptor;
-<BR><FONT COLOR="#FF0000">//Create a Connector</FONT>
-<BR>typedef ACE_Connector&lt;MyServiceHandler,ACE_SOCK_CONNECTOR> Connector;
-
-<P>class MyServiceHandler:
-<BR>public ACE_Svc_Handler&lt;ACE_SOCK_STREAM,ACE_NULL_SYNCH>{
-<BR>public:
-<BR><FONT COLOR="#FF0000">&nbsp;//Used by the two threads "globally" to
-determine their peer stream</FONT>
-<BR>&nbsp;static ACE_SOCK_Stream* Peer;
-
-<P><FONT COLOR="#FF0000">//Thread ID used to identify the threads</FONT>
-<BR>&nbsp;ACE_thread_t t_id;
-
-<P>int open(void*){
-<BR>&nbsp; ACE_DEBUG((LM_DEBUG,"Acceptor: received new connection\n"));
-
-<P><FONT COLOR="#FF0000">//Register with the reactor to remember this handlle</FONT>
-<BR>&nbsp; Reactor::instance() ->register_handler(this,ACE_Event_Handler::READ_MASK);
-
-<P><FONT COLOR="#FF0000">//Determine the peer stream and record it globally</FONT>
-<BR>&nbsp; MyServiceHandler::Peer=&amp;peer();
-<BR>&nbsp;
-<BR>&nbsp; <FONT COLOR="#FF0000">//Spawn new thread to send string every
-second</FONT>
-<BR>&nbsp; ACE_Thread::spawn((ACE_THR_FUNC)send_data,0,THR_NEW_LWP,&amp;t_id);
-<BR>&nbsp;
-<BR>&nbsp;<FONT COLOR="#FF0000"> //keep the service handler registered
-by returning 0 to the reactor</FONT>
-<BR>&nbsp; return 0;
-<BR>&nbsp; }
-<BR>&nbsp;
-
-<P>static void* send_data(void*){
-<BR>&nbsp; while(1){
-<BR>&nbsp;&nbsp; ACE_DEBUG((LM_DEBUG,"Hello World\n"));
-<BR>&nbsp;&nbsp; Peer->send_n("Hello World",sizeof("Hello World"));
-<BR>&nbsp;
-<BR>&nbsp;&nbsp; <FONT COLOR="#FF0000">//Go to sleep for a second before
-sending again</FONT>
-<BR>&nbsp;&nbsp; ACE_OS::sleep(1);
-<BR>&nbsp;&nbsp;&nbsp; }
-<BR>&nbsp; return 0;
-<BR>&nbsp; }
-<BR>&nbsp;
-
-<P>int handle_input(ACE_HANDLE){
-<BR>&nbsp; char* data= new char[12];
-<BR>&nbsp;
-<BR>&nbsp;<FONT COLOR="#FF0000"> //Check if peer aborted the connection</FONT>
-<BR>&nbsp; if(Peer.recv_n(data,12)==0){
-<BR>&nbsp;&nbsp; ACE_DEBUG((LM_DEBUG,"Peer probably aborted connection\n"));
-<BR>&nbsp;&nbsp; ACE_Thread::cancel(t_id); <FONT COLOR="#CC0000">//kill
-sending thread ..</FONT>
-<BR>&nbsp;&nbsp; return -1; <FONT COLOR="#FF0000">//de-register from the
-Reactor.</FONT>
-<BR>&nbsp;&nbsp; }
-
-<P>&nbsp;<FONT COLOR="#FF0000"> //Show what you got..</FONT>
-<BR>&nbsp; ACE_DEBUG((LM_DEBUG,"&lt;&lt; %s\n",data));
-<BR>&nbsp;
-<BR>&nbsp; <FONT COLOR="#FF0000">//keep yourself registered</FONT>
-<BR>&nbsp; return 0;
-<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
-<BR>};
-
-<P><FONT COLOR="#FF0000">//Global stream identifier used by both threads</FONT>
-<BR>ACE_SOCK_Stream * MyServiceHandler::Peer=0;
-<BR>&nbsp;
-
-<P>void main_accept(){
-<BR>&nbsp;ACE_INET_Addr addr(PORT_NO);
-<BR>&nbsp;Acceptor myacceptor(addr,Reactor::instance());
-<BR>&nbsp;while(1)
-<BR>&nbsp; Reactor::instance()->handle_events();
-
-<P>&nbsp;return 0;
-<BR>&nbsp;}
-
-<P>void main_connect(){
-<BR>&nbsp;ACE_INET_Addr addr(PORT_NO,HOSTNAME);
-<BR>&nbsp;Connector myconnector;
-<BR>&nbsp;myconnector.connect(my_svc_handler,addr);
-<BR>&nbsp;while(1)
-<BR>&nbsp; Reactor::instance()->handle_events();
-
-<P>&nbsp;}
-<BR>&nbsp;
-
-<P>int main(int argc, char* argv[]){
-<BR><FONT COLOR="#FF0000">&nbsp;// Use ACE_Get_Opt to parse and obtain
-arguments and then call the</FONT>
-<BR>&nbsp;<FONT COLOR="#FF0000">// approriate function for accept or connect.</FONT>
-<BR><FONT COLOR="#CC0000">//...</FONT>
-<BR>}
-<BR>&nbsp;
-<BR>&nbsp;<A HREF="ex06.html">Next Example</A>
-</BODY>
-</HTML>