mirror of
https://github.com/thestk/stk
synced 2026-01-13 13:01:52 +00:00
231 lines
12 KiB
HTML
231 lines
12 KiB
HTML
<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.4.4 -->
|
|
<h1>UdpSocket Class Reference</h1><!-- doxytag: class="UdpSocket" --><!-- doxytag: inherits="Socket" --><code>#include <<a class="el" href="UdpSocket_8h-source.html">UdpSocket.h</a>></code>
|
|
<p>
|
|
<p>Inheritance diagram for UdpSocket:
|
|
<p><center><img src="classUdpSocket.png" usemap="#UdpSocket_map" border="0" alt=""></center>
|
|
<map name="UdpSocket_map">
|
|
<area href="classSocket.html" alt="Socket" shape="rect" coords="0,56,72,80">
|
|
<area href="classStk.html" alt="Stk" shape="rect" coords="0,0,72,24">
|
|
</map>
|
|
<a href="classUdpSocket-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
|
|
STK UDP socket server/client class.
|
|
<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>
|
|
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>
|
|
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>
|
|
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
|
<p>
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
<tr><td></td></tr>
|
|
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#a0">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="#a0"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1"></a><!-- doxytag: member="UdpSocket::~UdpSocket" ref="a1" args="()" -->
|
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#a1">~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" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#a2">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="classUdpSocket.html#a3">writeBuffer()</a></em> function. <a href="#a2"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#a3">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="classUdpSocket.html#a2">setDestination()</a></em> function. Returns the number of bytes written or -1 if an error occurs. <a href="#a3"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a4"></a><!-- doxytag: member="UdpSocket::readBuffer" ref="a4" args="(void *buffer, long bufferSize, int flags=0)" -->
|
|
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#a4">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" nowrap align="right" valign="top"><a class="anchor" name="a5"></a><!-- doxytag: member="UdpSocket::writeBufferTo" ref="a5" 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="classUdpSocket.html#a5">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"><br><h2>Protected Member Functions</h2></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUdpSocket.html#b0">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="#b0"></a><br></td></tr>
|
|
</table>
|
|
<hr><h2>Constructor & Destructor Documentation</h2>
|
|
<a class="anchor" name="a0"></a><!-- doxytag: member="UdpSocket::UdpSocket" ref="a0" args="(int port=2006)" --><p>
|
|
<table class="mdTable" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top">UdpSocket::UdpSocket </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">int </td>
|
|
<td class="mdname1" valign="top" nowrap> <em>port</em> = <code>2006</code> </td>
|
|
<td class="md" valign="top"> ) </td>
|
|
<td class="md" nowrap></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing="5" cellpadding="0" border="0">
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<td>
|
|
|
|
<p>
|
|
Default constructor creates a local UDP socket on port 2006 (or the specified port number).
|
|
<p>
|
|
An <a class="el" href="classStkError.html">StkError</a> will be thrown if a socket error occurs during instantiation. </td>
|
|
</tr>
|
|
</table>
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<a class="anchor" name="a2"></a><!-- doxytag: member="UdpSocket::setDestination" ref="a2" args="(int port=2006, std::string hostname="localhost")" --><p>
|
|
<table class="mdTable" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top">void UdpSocket::setDestination </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">int </td>
|
|
<td class="mdname" nowrap> <em>port</em> = <code>2006</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md" nowrap align="right"></td>
|
|
<td class="md"></td>
|
|
<td class="md" nowrap>std::string </td>
|
|
<td class="mdname" nowrap> <em>hostname</em> = <code>"localhost"</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md"></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 address for subsequent outgoing data sent via the <em><a class="el" href="classUdpSocket.html#a3">writeBuffer()</a></em> function.
|
|
<p>
|
|
An <a class="el" href="classStkError.html">StkError</a> will be thrown if the host is unknown. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="a3"></a><!-- doxytag: member="UdpSocket::writeBuffer" ref="a3" args="(const void *buffer, long bufferSize, int flags=0)" --><p>
|
|
<table class="mdTable" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top">int UdpSocket::writeBuffer </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">const void * </td>
|
|
<td class="mdname" nowrap> <em>buffer</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md" nowrap align="right"></td>
|
|
<td class="md"></td>
|
|
<td class="md" nowrap>long </td>
|
|
<td class="mdname" nowrap> <em>bufferSize</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md" nowrap align="right"></td>
|
|
<td class="md"></td>
|
|
<td class="md" nowrap>int </td>
|
|
<td class="mdname" nowrap> <em>flags</em> = <code>0</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md"></td>
|
|
<td class="md">) </td>
|
|
<td class="md" colspan="2"><code> [virtual]</code></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing="5" cellpadding="0" border="0">
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<td>
|
|
|
|
<p>
|
|
Send a buffer to the address specified with the <em><a class="el" href="classUdpSocket.html#a2">setDestination()</a></em> function. Returns the number of bytes written or -1 if an error occurs.
|
|
<p>
|
|
This function will fail if the default address (set with <em><a class="el" href="classUdpSocket.html#a2">setDestination()</a></em>) is invalid or has not been specified.
|
|
<p>
|
|
Implements <a class="el" href="classSocket.html#a4">Socket</a>. </td>
|
|
</tr>
|
|
</table>
|
|
<a class="anchor" name="b0"></a><!-- doxytag: member="UdpSocket::setAddress" ref="b0" args="(struct sockaddr_in *address, int port=2006, std::string hostname="localhost")" --><p>
|
|
<table class="mdTable" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td class="mdRow">
|
|
<table cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td class="md" nowrap valign="top">void UdpSocket::setAddress </td>
|
|
<td class="md" valign="top">( </td>
|
|
<td class="md" nowrap valign="top">struct sockaddr_in * </td>
|
|
<td class="mdname" nowrap> <em>address</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md" nowrap align="right"></td>
|
|
<td class="md"></td>
|
|
<td class="md" nowrap>int </td>
|
|
<td class="mdname" nowrap> <em>port</em> = <code>2006</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md" nowrap align="right"></td>
|
|
<td class="md"></td>
|
|
<td class="md" nowrap>std::string </td>
|
|
<td class="mdname" nowrap> <em>hostname</em> = <code>"localhost"</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="md"></td>
|
|
<td class="md">) </td>
|
|
<td class="md" colspan="2"><code> [protected]</code></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table cellspacing="5" cellpadding="0" border="0">
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<td>
|
|
|
|
<p>
|
|
A protected function for use in writing a socket address structure.
|
|
<p>
|
|
An <a class="el" href="classStkError.html">StkError</a> will be thrown if the host is unknown. </td>
|
|
</tr>
|
|
</table>
|
|
<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></ul>
|
|
<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-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|