<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ost::UDPSocket class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.10 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> <hr><h1>ost::UDPSocket Class Reference</h1>UDP sockets implement the TCP SOCK_DGRAM UDP protocol. Unreliable Datagram Protocol sockets. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="socket_8h-source.html">socket.h</a>></code> <p> <p>Inheritance diagram for ost::UDPSocket:: <p><center><img src="classost_1_1_u_d_p_socket.gif" usemap="#ost::UDPSocket_map" border="0"></center> <map name="ost::UDPSocket_map"> <area href="classost_1_1_socket.html" alt="ost::Socket" shape="rect" coords="126,0,242,24"> <area href="classost_1_1_u_d_p_broadcast.html" alt="ost::UDPBroadcast" shape="rect" coords="0,112,116,136"> <area href="classost_1_1_u_d_p_receive.html" alt="ost::UDPReceive" shape="rect" coords="126,112,242,136"> <area href="classost_1_1_u_d_p_transmit.html" alt="ost::UDPTransmit" shape="rect" coords="252,112,368,136"> <area href="classost_1_1_u_d_p_duplex.html" alt="ost::UDPDuplex" shape="rect" coords="126,168,242,192"> <area href="classost_1_1_u_d_p_duplex.html" alt="ost::UDPDuplex" shape="rect" coords="252,168,368,192"> </map> <a href="classost_1_1_u_d_p_socket-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a0">UDPSocket</a> (void)</td></tr> <tr><td> </td><td><font size=-1><em>Create an unbound UDP socket, mostly for internal use.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a1">UDPSocket</a> (const <a class="el" href="classost_1_1_inet_address.html">InetAddress</a> &bind, <a class="el" href="namespaceost.html#a97">tpport_t</a> port)</td></tr> <tr><td> </td><td><font size=-1><em>Create a UDP socket and bind it to a specific interface and port address so that other UDP sockets on remote machines (or the same host) may find and send UDP messages to it.</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>virtual </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a2">~UDPSocket</a> ()</td></tr> <tr><td> </td><td><font size=-1><em>Destroy a UDP socket as a socket.</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a3">setPeer</a> (const <a class="el" href="classost_1_1_inet_host_address.html">InetHostAddress</a> &host, <a class="el" href="namespaceost.html#a97">tpport_t</a> port)</td></tr> <tr><td> </td><td><font size=-1><em>set the peer address to send message packets to.</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a4">Send</a> (const void *buf, size_t len)</td></tr> <tr><td> </td><td><font size=-1><em>Send a message packet to a peer host.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a5">Recv</a> (void *buf, size_t len)</td></tr> <tr><td> </td><td><font size=-1><em>Receive a message from any host.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top><a class="el" href="classost_1_1_inet_host_address.html">InetHostAddress</a> </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a6">getPeer</a> (<a class="el" href="namespaceost.html#a97">tpport_t</a> *port=NULL) const</td></tr> <tr><td> </td><td><font size=-1><em>Examine address of sender of next waiting packet.</em> <a href="#a6">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#a7">Peek</a> (void *buf, size_t len)</td></tr> <tr><td> </td><td><font size=-1><em>Examine contents of next waiting packet.</em> <a href="#a7">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr> <tr><td nowrap align=right valign=top>sockaddr_in </td><td valign=bottom><a class="el" href="classost_1_1_u_d_p_socket.html#n0">peer</a></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> UDP sockets implement the TCP SOCK_DGRAM UDP protocol. Unreliable Datagram Protocol sockets. <p> They can be used to pass unverified messages between hosts, or to broadcast a specific message to an entire subnet. Please note that Streaming of realtime data commonly use <a class="el" href="classost_1_1_u_d_p_duplex.html">UDPDuplex</a> related classes rather than <a class="el" href="classost_1_1_u_d_p_socket.html">UDPSocket</a>. <p> In addition to connected TCP sessions, Common C++ supports UDP sockets and these also cover a range of functionality. Like a <a class="el" href="classost_1_1_t_c_p_socket.html">TCPSocket</a>, A <a class="el" href="classost_1_1_u_d_p_socket.html">UDPSocket</a> can be created bound to a specific network interface and/or port address, though this is not required. UDP sockets also are usually either connected or otherwise "associated" with a specific "peer" UDP socket. Since UDP sockets operate through discreet packets, there are no streaming operators used with UDP sockets. <p> In addition to the UDP "socket" class, there is a "<a class="el" href="classost_1_1_u_d_p_broadcast.html">UDPBroadcast</a>" class. The <a class="el" href="classost_1_1_u_d_p_broadcast.html">UDPBroadcast</a> is a socket that is set to send messages to a subnet as a whole rather than to an individual peer socket that it may be associated with. <p> UDP sockets are often used for building "realtime" media streaming protocols and full duplex messaging services. When used in this manner, typically a pair of UDP sockets are used together; one socket is used to send and the other to receive data with an associated pair of UDP sockets on a "peer" host. This concept is represented through the Common C++ <a class="el" href="classost_1_1_u_d_p_duplex.html">UDPDuplex</a> object, which is a pair of sockets that communicate with another <a class="el" href="classost_1_1_u_d_p_duplex.html">UDPDuplex</a> pair. <p> <dl compact><dt><b> Author: </b><dd> David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> </dl> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a name="a0" doxytag="ost::UDPSocket::UDPSocket"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> ost::UDPSocket::UDPSocket </td> <td class="md">( </td> <td class="md">void</td> <td class="mdname1"> </td> <td class="md">) </td> <td class="md"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Create an unbound UDP socket, mostly for internal use. <p> </td> </tr> </table> <a name="a1" doxytag="ost::UDPSocket::UDPSocket"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> ost::UDPSocket::UDPSocket </td> <td class="md">( </td> <td class="md">const <a class="el" href="classost_1_1_inet_address.html">InetAddress</a> &</td> <td class="mdname"> <em>bind</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md"><a class="el" href="namespaceost.html#a97">tpport_t</a></td> <td class="mdname"> <em>port</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Create a UDP socket and bind it to a specific interface and port address so that other UDP sockets on remote machines (or the same host) may find and send UDP messages to it. <p> On failure to bind, an exception is thrown.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>bind </em> </td><td> address to bind this socket to. </td></tr> <tr><td valign=top><em>port </em> </td><td> number to bind this socket to. </td></tr> </table> </dl> </td> </tr> </table> <a name="a2" doxytag="ost::UDPSocket::~UDPSocket"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual ost::UDPSocket::~UDPSocket </td> <td class="md">( </td> <td class="mdname1"> </td> <td class="md">) </td> <td class="md"><code> [virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Destroy a UDP socket as a socket. <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="a7" doxytag="ost::UDPSocket::Peek"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int ost::UDPSocket::Peek </td> <td class="md">( </td> <td class="md">void *</td> <td class="mdname"> <em>buf</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md">size_t</td> <td class="mdname"> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Examine contents of next waiting packet. <p> <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pointer </em> </td><td> to packet buffer for contents. </td></tr> <tr><td valign=top><em>len </em> </td><td> of packet buffer. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> number of bytes examined. </dl> </td> </tr> </table> <a name="a5" doxytag="ost::UDPSocket::Recv"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int ost::UDPSocket::Recv </td> <td class="md">( </td> <td class="md">void *</td> <td class="mdname"> <em>buf</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md">size_t</td> <td class="mdname"> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Receive a message from any host. <p> <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pointer </em> </td><td> to packet buffer to receive. </td></tr> <tr><td valign=top><em>len </em> </td><td> of packet buffer to receive. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> number of bytes received. </dl> </td> </tr> </table> <a name="a4" doxytag="ost::UDPSocket::Send"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int ost::UDPSocket::Send </td> <td class="md">( </td> <td class="md">const void *</td> <td class="mdname"> <em>buf</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md">size_t</td> <td class="mdname"> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Send a message packet to a peer host. <p> <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pointer </em> </td><td> to packet buffer to send. </td></tr> <tr><td valign=top><em>len </em> </td><td> of packet buffer to send. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> number of bytes sent. </dl> </td> </tr> </table> <a name="a6" doxytag="ost::UDPSocket::getPeer"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> <a class="el" href="classost_1_1_inet_host_address.html">InetHostAddress</a> ost::UDPSocket::getPeer </td> <td class="md">( </td> <td class="md"><a class="el" href="namespaceost.html#a97">tpport_t</a> *</td> <td class="mdname1"> <em>port</em> = NULL </td> <td class="md">) </td> <td class="md"> const</td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Examine address of sender of next waiting packet. <p> This also sets "peer" address to the sender so that the next "send" message acts as a "reply". This additional behavior overides the standard socket getSender behavior.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pointer </em> </td><td> to hold port number. </td></tr> </table> </dl> <p> Reimplemented from <a class="el" href="classost_1_1_socket.html#a3">ost::Socket</a>. </td> </tr> </table> <a name="a3" doxytag="ost::UDPSocket::setPeer"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void ost::UDPSocket::setPeer </td> <td class="md">( </td> <td class="md">const <a class="el" href="classost_1_1_inet_host_address.html">InetHostAddress</a> &</td> <td class="mdname"> <em>ia</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md"><a class="el" href="namespaceost.html#a97">tpport_t</a></td> <td class="mdname"> <em>port</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> set the peer address to send message packets to. <p> This can be set before every <a class="el" href="classost_1_1_u_d_p_socket.html#a4">Send</a>() call if nessisary.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>host </em> </td><td> address to send packets to. </td></tr> <tr><td valign=top><em>port </em> </td><td> number to deliver packets to. </td></tr> </table> </dl> </td> </tr> </table> <hr><h2>Member Data Documentation</h2> <a name="n0" doxytag="ost::UDPSocket::peer"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> struct sockaddr_in ost::UDPSocket::peer<code> [protected]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="socket_8h-source.html">socket.h</a></ul> <hr><address><small>Generated at Fri Jan 4 18:51:52 2002 for CommonC++ by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.gif" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.10 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2001</small></address> </body> </html>