diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-09 04:56:15 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-09 04:56:15 +0000 |
commit | 188b6b729d4d65c06c3697312c5ad9e00e55e7c6 (patch) | |
tree | 4fad3672c0e3a1b5b071e50a4ba83236da9b1bda /docs/tutorials | |
parent | b79bb632615ceaeb049f7a5257dcc5f524169dd2 (diff) | |
download | ATCD-188b6b729d4d65c06c3697312c5ad9e00e55e7c6.tar.gz |
.
Diffstat (limited to 'docs/tutorials')
-rw-r--r-- | docs/tutorials/Chap_2/ex04.html | 2 | ||||
-rw-r--r-- | docs/tutorials/Chap_2/ex05.html | 87 |
2 files changed, 88 insertions, 1 deletions
diff --git a/docs/tutorials/Chap_2/ex04.html b/docs/tutorials/Chap_2/ex04.html index 41cf78188bd..16007f9c8f1 100644 --- a/docs/tutorials/Chap_2/ex04.html +++ b/docs/tutorials/Chap_2/ex04.html @@ -82,6 +82,6 @@ sent wait for a reply from</FONT> <BR>client.send_data(); <BR>} <BR> -<BR> <A HREF="ex05.htm">Next Example</A> +<BR> <A HREF="ex05.html">Next Example</A> </BODY> </HTML> diff --git a/docs/tutorials/Chap_2/ex05.html b/docs/tutorials/Chap_2/ex05.html new file mode 100644 index 00000000000..1a88e7c8dbd --- /dev/null +++ b/docs/tutorials/Chap_2/ex05.html @@ -0,0 +1,87 @@ +<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">//// Chapter: "IPC SAP" (Interprocess Communication +Mechanisms in ACE).</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">//// 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/SOCK_Dgram_Mcast.h"</FONT> +<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> +<BR><FONT COLOR="#000099">#define</FONT> <FONT COLOR="#663366">DEFAULT_MULTICAST_ADDR +"224.9.9.2"</FONT> +<BR><FONT COLOR="#000099">#define</FONT> <FONT COLOR="#663366">TIMEOUT +5</FONT> + +<P>class Reciever_Multicast{ + +<P>public: +<BR>Reciever_Multicast(int port): +<BR> mcast_addr_(port,DEFAULT_MULTICAST_ADDR),remote_addr_((u_short)0){ +<BR> <FONT COLOR="#FF0000"> // Subscribe to multicast address.</FONT> +<BR> if (mcast_dgram_.subscribe (mcast_addr_) == -1){ +<BR> ACE_DEBUG((LM_DEBUG,"Error in subscribing to Multicast address +\n")); +<BR> exit(-1); +<BR> } +<BR>} + +<P>~Reciever_Multicast(){ +<BR> if(mcast_dgram_.unsubscribe()==-1) +<BR> ACE_DEBUG((LM_ERROR,?Error in unsubscribing from Mcast group\n?)); +<BR> } +<BR> +<BR> +<BR> + +<P><FONT COLOR="#FF0000">//Receive data from someone who is sending data +on the multicast group</FONT> +<BR><FONT COLOR="#FF0000">//address to do so it must use the multicast +datagram component</FONT> +<BR><FONT COLOR="#FF0000">//mcast_dgram_.</FONT> +<BR>int recv_multicast(){ +<BR><FONT COLOR="#FF0000"> //get ready to recieve data from the sender.</FONT> +<BR> if(mcast_dgram_.recv +<BR> (&mcast_info,sizeof (mcast_info),remote_addr_)==-1) +<BR> return -1; +<BR> ACE_DEBUG ((LM_DEBUG, "(%P|%t) Received multicast from %s:%d.\n", +<BR> remote_addr_.get_host_name(), remote_addr_.get_port_number())); +<BR> ACE_DEBUG((LM_DEBUG,"Successfully receieved %d\n", mcast_info)); +<BR> return 0; +<BR> } + +<P>private: +<BR> ACE_INET_Addr mcast_addr_; +<BR> ACE_INET_Addr remote_addr_; +<BR> ACE_SOCK_Dgram_Mcast mcast_dgram_; +<BR> int mcast_info; +<BR>}; +<BR> +<BR> +<BR>int main(int argc, char*argv[]){ +<BR> Reciever_Multicast m(2000); +<BR> <FONT COLOR="#FF0000">//Will run forever</FONT> +<BR> while(m.recv_multicast()!=-1) { +<BR> ACE_DEBUG((LM_DEBUG,"Multicaster succesful \n")); +<BR> } +<BR> +<BR> ACE_DEBUG((LM_ERROR,"Multicaster failed \n")); +<BR> exit(-1); +<BR>} + +<P> <A HREF="ex06.html">Next Example</A> +<BR> +</BODY> +</HTML> |