1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.6.2 -->
<div class="navpath"><a class="el" href="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1UdpSocket.html">UdpSocket</a>
</div>
<div class="contents">
<h1>stk::UdpSocket Class Reference</h1><!-- doxytag: class="stk::UdpSocket" --><!-- doxytag: inherits="stk::Socket" -->
<p>STK UDP socket server/client class.
<a href="#_details">More...</a></p>
<p><code>#include <<a class="el" href="UdpSocket_8h_source.html">UdpSocket.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for stk::UdpSocket:</div>
<div class="dynsection">
<div class="center">
<img src="classstk_1_1UdpSocket.png" usemap="#stk::UdpSocket_map" alt=""/>
<map id="stk::UdpSocket_map" name="stk::UdpSocket_map">
<area href="classstk_1_1Socket.html" alt="stk::Socket" shape="rect" coords="0,56,93,80"/>
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,93,24"/>
</map>
</div>
</div>
<p><a href="classstk_1_1UdpSocket-members.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#aaad5171c74b4ab7c2155cd63ef30a271">UdpSocket</a> (int port=2006)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor creates a local UDP socket on port 2006 (or the specified port number). <a href="#aaad5171c74b4ab7c2155cd63ef30a271"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9b54f5d058c01c04dc266f117da7ee2a"></a><!-- doxytag: member="stk::UdpSocket::~UdpSocket" ref="a9b54f5d058c01c04dc266f117da7ee2a" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#a9b54f5d058c01c04dc266f117da7ee2a">~UdpSocket</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">The class destructor closes the socket instance. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#a4267442661257aae2a0f6b48d367fea1">setDestination</a> (int port=2006, std::string hostname="localhost")</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the address for subsequent outgoing data sent via the <em><a class="el" href="classstk_1_1UdpSocket.html#aa9d3d734b4e9c811724eff626e849cb8" title="Send a buffer to the address specified with the setDestination() function. Returns...">writeBuffer()</a></em> function. <a href="#a4267442661257aae2a0f6b48d367fea1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#aa9d3d734b4e9c811724eff626e849cb8">writeBuffer</a> (const void *buffer, long bufferSize, int flags=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Send a buffer to the address specified with the <em><a class="el" href="classstk_1_1UdpSocket.html#a4267442661257aae2a0f6b48d367fea1" title="Set the address for subsequent outgoing data sent via the writeBuffer() function...">setDestination()</a></em> function. Returns the number of bytes written or -1 if an error occurs. <a href="#aa9d3d734b4e9c811724eff626e849cb8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1f66fdcc40b07f9d56e472be9684adcb"></a><!-- doxytag: member="stk::UdpSocket::readBuffer" ref="a1f66fdcc40b07f9d56e472be9684adcb" args="(void *buffer, long bufferSize, int flags=0)" -->
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#a1f66fdcc40b07f9d56e472be9684adcb">readBuffer</a> (void *buffer, long bufferSize, int flags=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Read an input buffer, up to length <em>bufferSize</em>. Returns the number of bytes read or -1 if an error occurs. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a85f74161d2d3697593f08bda9dcb8963"></a><!-- doxytag: member="stk::UdpSocket::writeBufferTo" ref="a85f74161d2d3697593f08bda9dcb8963" args="(const void *buffer, long bufferSize, int port, std::string hostname="localhost", int flags=0)" -->
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#a85f74161d2d3697593f08bda9dcb8963">writeBufferTo</a> (const void *buffer, long bufferSize, int port, std::string hostname="localhost", int flags=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Write a buffer to the specified socket. Returns the number of bytes written or -1 if an error occurs. <br/></td></tr>
<tr><td colspan="2"><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1UdpSocket.html#a785594fd882b76d4c280b72a016f026d">setAddress</a> (struct sockaddr_in *address, int port=2006, std::string hostname="localhost")</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">A protected function for use in writing a socket address structure. <a href="#a785594fd882b76d4c280b72a016f026d"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK UDP socket server/client class. </p>
<p>This class provides a uniform cross-platform UDP socket server/client interface. Methods are provided for reading or writing data buffers. The constructor creates a UDP socket and binds it to the specified port. Note that only one socket can be bound to a given port on the same machine.</p>
<p>UDP sockets provide unreliable, connection-less service. Messages can be lost, duplicated, or received out of order. That said, data transmission tends to be faster than with TCP connections and datagrams are not potentially combined by the underlying system.</p>
<p>The user is responsible for checking the values returned by the read/write methods. Values less than or equal to zero indicate the occurence of an error.</p>
<p>by Perry R. Cook and Gary P. Scavone, 1995-2012. </p>
<hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="aaad5171c74b4ab7c2155cd63ef30a271"></a><!-- doxytag: member="stk::UdpSocket::UdpSocket" ref="aaad5171c74b4ab7c2155cd63ef30a271" args="(int port=2006)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">stk::UdpSocket::UdpSocket </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>port</em> = <code>2006</code></td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Default constructor creates a local UDP socket on port 2006 (or the specified port number). </p>
<p>An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if a socket error occurs during instantiation. </p>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a4267442661257aae2a0f6b48d367fea1"></a><!-- doxytag: member="stk::UdpSocket::setDestination" ref="a4267442661257aae2a0f6b48d367fea1" args="(int port=2006, std::string hostname="localhost")" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::UdpSocket::setDestination </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>port</em> = <code>2006</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::string </td>
<td class="paramname"> <em>hostname</em> = <code>"localhost"</code></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the address for subsequent outgoing data sent via the <em><a class="el" href="classstk_1_1UdpSocket.html#aa9d3d734b4e9c811724eff626e849cb8" title="Send a buffer to the address specified with the setDestination() function. Returns...">writeBuffer()</a></em> function. </p>
<p>An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if the host is unknown. </p>
</div>
</div>
<a class="anchor" id="aa9d3d734b4e9c811724eff626e849cb8"></a><!-- doxytag: member="stk::UdpSocket::writeBuffer" ref="aa9d3d734b4e9c811724eff626e849cb8" args="(const void *buffer, long bufferSize, int flags=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int stk::UdpSocket::writeBuffer </td>
<td>(</td>
<td class="paramtype">const void * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long </td>
<td class="paramname"> <em>bufferSize</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>flags</em> = <code>0</code></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Send a buffer to the address specified with the <em><a class="el" href="classstk_1_1UdpSocket.html#a4267442661257aae2a0f6b48d367fea1" title="Set the address for subsequent outgoing data sent via the writeBuffer() function...">setDestination()</a></em> function. Returns the number of bytes written or -1 if an error occurs. </p>
<p>This function will fail if the default address (set with <em><a class="el" href="classstk_1_1UdpSocket.html#a4267442661257aae2a0f6b48d367fea1" title="Set the address for subsequent outgoing data sent via the writeBuffer() function...">setDestination()</a></em>) is invalid or has not been specified. </p>
<p>Implements <a class="el" href="classstk_1_1Socket.html#a7938202181552306d0ea74c6c04abf4a">stk::Socket</a>.</p>
</div>
</div>
<a class="anchor" id="a785594fd882b76d4c280b72a016f026d"></a><!-- doxytag: member="stk::UdpSocket::setAddress" ref="a785594fd882b76d4c280b72a016f026d" args="(struct sockaddr_in *address, int port=2006, std::string hostname="localhost")" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::UdpSocket::setAddress </td>
<td>(</td>
<td class="paramtype">struct sockaddr_in * </td>
<td class="paramname"> <em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>port</em> = <code>2006</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::string </td>
<td class="paramname"> <em>hostname</em> = <code>"localhost"</code></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>A protected function for use in writing a socket address structure. </p>
<p>An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if the host is unknown. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="UdpSocket_8h_source.html">UdpSocket.h</a></li>
</ul>
</div>
<HR>
<table>
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
<tr><td>©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>
|