chromium/native_client_sdk/doc_generated/pepper_stable/cpp/classpp_1_1_u_d_p_socket.html

{{+bindTo:partials.standard_nacl_api}}
<h1>pp::UDPSocket Class Reference</h1>
<div id="doxygen-ref">
{{- dummy div to appease doxygen -}}
  <div>
<!-- Generated by Doxygen 1.7.6.1 -->



</div>
<!--header-->
<div class="contents">
<!-- doxytag: class="pp::UDPSocket" --><!-- doxytag: inherits="pp::Resource" --><div class="dynheader">
Inheritance diagram for pp::UDPSocket:</div>
<div class="dyncontent">
<div class="center"><img src="classpp_1_1_u_d_p_socket__inherit__graph.png" border="0" usemap="#pp_1_1_u_d_p_socket_inherit__map" alt="Inheritance graph" /></div>
<map name="pp_1_1_u_d_p_socket_inherit__map" id="pp_1_1_u_d_p_socket_inherit__map">
<area shape="rect" id="node2" href="classpp_1_1_resource.html" title="A reference counted module resource." alt="" coords="12,5,116,32"></area></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<p><a href="classpp_1_1_u_d_p_socket-members.html">List of all members.</a></p>
<h2>
Public Member Functions</h2><table class="memberdecls">

<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#aba8a6c1b62bc3c8883296a9445131da5">UDPSocket</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#aa2b691e69558b5d7d43a91bd61550b2c">UDPSocket</a> (const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> &amp;instance)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#ac824fba529205830d0c2c54a21ed449b">UDPSocket</a> (<a class="el" href="namespacepp.html#a339083c1beec620267bf8b3c55decaa5">PassRef</a>, PP_Resource resource)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a88fb9b2ed5c7726d0f4bf55948ef5be2">UDPSocket</a> (const <a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a> &amp;other)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a5fe143ce6bcaf1ac67748325acde1c50">~UDPSocket</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a72112f67b757bbbfaaf67ae3cfe2f602">operator=</a> (const <a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a> &amp;other)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a5f9b7edf613c59091eb66dc074d7f7c1">Bind</a> (const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;addr, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classpp_1_1_net_address.html">NetAddress</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#ae98c9decb3c3ea4ba1006943577b684d">GetBoundAddress</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a496b1742a9b4ef27d23c9b4b96b9fd0a">RecvFrom</a> (char *buffer, int32_t num_bytes, const <a class="el" href="classpp_1_1_completion_callback_with_output.html">CompletionCallbackWithOutput</a>&lt; <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &gt; &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a657309cd3bc38cf28e25f4c71190d1a0">SendTo</a> (const char *buffer, int32_t num_bytes, const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;addr, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#aa1f03d8d0e7ef59c40724e2691f165f2">Close</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a5ff91fd2342e534b57980c0c2e414251">SetOption</a> (PP_UDPSocket_Option name, const <a class="el" href="classpp_1_1_var.html">Var</a> &amp;value, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a51bdeaeeef690d741850e7d691fa479d">JoinGroup</a> (const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;group, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a7efaa9eda9e58ffbd5f6b5c5c9e8b38c">LeaveGroup</a> (const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;group, const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> callback)</td></tr>
</table><h2>
Static Public Member Functions</h2><table class="memberdecls">
<tr><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpp_1_1_u_d_p_socket.html#a76a2e93f2fa01d0dce8d8216d53b4f44">IsAvailable</a> ()</td></tr>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>The <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code> class provides UDP socket operations. </p>
<p>Permissions: Apps permission <code>socket</code> with subrule <code>udp-bind</code> is required for <code><a class="el" href="classpp_1_1_u_d_p_socket.html#a5f9b7edf613c59091eb66dc074d7f7c1" title="Binds the socket to the given address.">Bind()</a></code>; subrule <code>udp-send-to</code> is required for <code><a class="el" href="classpp_1_1_u_d_p_socket.html#a657309cd3bc38cf28e25f4c71190d1a0" title="Sends data to a specific destination.">SendTo()</a></code>. For more details about network communication permissions, please see: <a href="http://developer.chrome.com/apps/app_network.html">http://developer.chrome.com/apps/app_network.html</a> </p>
</div><hr /><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aba8a6c1b62bc3c8883296a9445131da5"></a><!-- doxytag: member="pp::UDPSocket::UDPSocket" ref="aba8a6c1b62bc3c8883296a9445131da5" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_u_d_p_socket.html#aba8a6c1b62bc3c8883296a9445131da5">pp::UDPSocket::UDPSocket</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Default constructor for creating an <a class="el" href="classpp_1_1_resource.html#a859068e34cdc2dc0b78754c255323aa9" title="This functions determines if this resource is invalid or uninitialized.">is_null()</a> <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code> object. </p>
</div>
</div>
<a class="anchor" id="aa2b691e69558b5d7d43a91bd61550b2c"></a><!-- doxytag: member="pp::UDPSocket::UDPSocket" ref="aa2b691e69558b5d7d43a91bd61550b2c" args="(const InstanceHandle &amp;instance)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_u_d_p_socket.html#aba8a6c1b62bc3c8883296a9445131da5">pp::UDPSocket::UDPSocket</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_instance_handle.html">InstanceHandle</a> &amp;&#160;</td>
<td class="paramname"><em>instance</em></td><td>)</td>
<td><code> [explicit]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>A constructor used to create a <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code> object. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>The instance with which this resource will be associated. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ac824fba529205830d0c2c54a21ed449b"></a><!-- doxytag: member="pp::UDPSocket::UDPSocket" ref="ac824fba529205830d0c2c54a21ed449b" args="(PassRef, PP_Resource resource)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_u_d_p_socket.html#aba8a6c1b62bc3c8883296a9445131da5">pp::UDPSocket::UDPSocket</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="namespacepp.html#a339083c1beec620267bf8b3c55decaa5">PassRef</a>&#160;</td>
<td class="paramname">, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PP_Resource&#160;</td>
<td class="paramname"><em>resource</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>A constructor used when you have received a <code>PP_Resource</code> as a return value that has had 1 ref added for you. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">resource</td><td>A <code>PPB_UDPSocket</code> resource. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a88fb9b2ed5c7726d0f4bf55948ef5be2"></a><!-- doxytag: member="pp::UDPSocket::UDPSocket" ref="a88fb9b2ed5c7726d0f4bf55948ef5be2" args="(const UDPSocket &amp;other)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_u_d_p_socket.html#aba8a6c1b62bc3c8883296a9445131da5">pp::UDPSocket::UDPSocket</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a> &amp;&#160;</td>
<td class="paramname"><em>other</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>The copy constructor for <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code>. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">other</td><td>A reference to another <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code>. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a5fe143ce6bcaf1ac67748325acde1c50"></a><!-- doxytag: member="pp::UDPSocket::~UDPSocket" ref="a5fe143ce6bcaf1ac67748325acde1c50" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classpp_1_1_u_d_p_socket.html#a5fe143ce6bcaf1ac67748325acde1c50">pp::UDPSocket::~UDPSocket</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>The destructor. </p>
</div>
</div>
<hr /><h2>Member Function Documentation</h2>
<a class="anchor" id="a5f9b7edf613c59091eb66dc074d7f7c1"></a><!-- doxytag: member="pp::UDPSocket::Bind" ref="a5f9b7edf613c59091eb66dc074d7f7c1" args="(const NetAddress &amp;addr, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a5f9b7edf613c59091eb66dc074d7f7c1">pp::UDPSocket::Bind</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;&#160;</td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Binds the socket to the given address. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> object. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have required permissions. <code>PP_ERROR_ADDRESS_IN_USE</code> will be returned if the address is already in use. </dd></dl>
</div>
</div>
<a class="anchor" id="aa1f03d8d0e7ef59c40724e2691f165f2"></a><!-- doxytag: member="pp::UDPSocket::Close" ref="aa1f03d8d0e7ef59c40724e2691f165f2" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classpp_1_1_u_d_p_socket.html#aa1f03d8d0e7ef59c40724e2691f165f2">pp::UDPSocket::Close</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Cancels all pending reads and writes, and closes the socket. </p>
<p>Any pending callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> if pending IO was interrupted. After a call to this method, no output paramters passed into previous <code><a class="el" href="classpp_1_1_u_d_p_socket.html#a496b1742a9b4ef27d23c9b4b96b9fd0a" title="Receives data from the socket and stores the source address.">RecvFrom()</a></code> calls will be accessed. It is not valid to call <code><a class="el" href="classpp_1_1_u_d_p_socket.html#a5f9b7edf613c59091eb66dc074d7f7c1" title="Binds the socket to the given address.">Bind()</a></code> again.</p>
<p>The socket is implicitly closed if it is destroyed, so you are not required to call this method. </p>
</div>
</div>
<a class="anchor" id="ae98c9decb3c3ea4ba1006943577b684d"></a><!-- doxytag: member="pp::UDPSocket::GetBoundAddress" ref="ae98c9decb3c3ea4ba1006943577b684d" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_net_address.html">NetAddress</a> <a class="el" href="classpp_1_1_u_d_p_socket.html#ae98c9decb3c3ea4ba1006943577b684d">pp::UDPSocket::GetBoundAddress</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Get the address that the socket is bound to. </p>
<p>The socket must be bound.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> object. The object will be null (i.e., <a class="el" href="classpp_1_1_resource.html#a859068e34cdc2dc0b78754c255323aa9" title="This functions determines if this resource is invalid or uninitialized.">is_null()</a> returns true) on failure. </dd></dl>
</div>
</div>
<a class="anchor" id="a76a2e93f2fa01d0dce8d8216d53b4f44"></a><!-- doxytag: member="pp::UDPSocket::IsAvailable" ref="a76a2e93f2fa01d0dce8d8216d53b4f44" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static bool <a class="el" href="classpp_1_1_u_d_p_socket.html#a76a2e93f2fa01d0dce8d8216d53b4f44">pp::UDPSocket::IsAvailable</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Static function for determining whether the browser supports the <code>PPB_UDPSocket</code> interface. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the interface is available, false otherwise. </dd></dl>
</div>
</div>
<a class="anchor" id="a51bdeaeeef690d741850e7d691fa479d"></a><!-- doxytag: member="pp::UDPSocket::JoinGroup" ref="a51bdeaeeef690d741850e7d691fa479d" args="(const NetAddress &amp;group, const CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a51bdeaeeef690d741850e7d691fa479d">pp::UDPSocket::JoinGroup</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;&#160;</td>
<td class="paramname"><em>group</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a>&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Joins the multicast group with address specified by <code>group</code> parameter, which is expected to be a <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> object. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">group</td><td>A <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> corresponding to the network address of the multicast group. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. </dd></dl>
</div>
</div>
<a class="anchor" id="a7efaa9eda9e58ffbd5f6b5c5c9e8b38c"></a><!-- doxytag: member="pp::UDPSocket::LeaveGroup" ref="a7efaa9eda9e58ffbd5f6b5c5c9e8b38c" args="(const NetAddress &amp;group, const CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a7efaa9eda9e58ffbd5f6b5c5c9e8b38c">pp::UDPSocket::LeaveGroup</a> </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;&#160;</td>
<td class="paramname"><em>group</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a>&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Leaves the multicast group with address specified by <code>group</code> parameter, which is expected to be a <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> object. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">group</td><td>A <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> corresponding to the network address of the multicast group. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. </dd></dl>
</div>
</div>
<a class="anchor" id="a72112f67b757bbbfaaf67ae3cfe2f602"></a><!-- doxytag: member="pp::UDPSocket::operator=" ref="a72112f67b757bbbfaaf67ae3cfe2f602" args="(const UDPSocket &amp;other)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a>&amp; pp::UDPSocket::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classpp_1_1_u_d_p_socket.html">UDPSocket</a> &amp;&#160;</td>
<td class="paramname"><em>other</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>The assignment operator for <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code>. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">other</td><td>A reference to another <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code>.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A reference to this <code><a class="el" href="classpp_1_1_u_d_p_socket.html" title="The UDPSocket class provides UDP socket operations.">UDPSocket</a></code> object. </dd></dl>
</div>
</div>
<a class="anchor" id="a496b1742a9b4ef27d23c9b4b96b9fd0a"></a><!-- doxytag: member="pp::UDPSocket::RecvFrom" ref="a496b1742a9b4ef27d23c9b4b96b9fd0a" args="(char *buffer, int32_t num_bytes, const CompletionCallbackWithOutput&lt; NetAddress &gt; &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a496b1742a9b4ef27d23c9b4b96b9fd0a">pp::UDPSocket::RecvFrom</a> </td>
<td>(</td>
<td class="paramtype">char *&#160;</td>
<td class="paramname"><em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int32_t&#160;</td>
<td class="paramname"><em>num_bytes</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback_with_output.html">CompletionCallbackWithOutput</a>&lt; <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Receives data from the socket and stores the source address. </p>
<p>The socket must be bound.</p>
<p><b>Caveat:</b> You should be careful about the lifetime of <code>buffer</code>. Typically you will use a <code><a class="el" href="classpp_1_1_completion_callback_factory.html" title="CompletionCallbackFactory&lt;T&gt; may be used to create CompletionCallback objects that are bound to membe...">CompletionCallbackFactory</a></code> to scope callbacks to the lifetime of your class. When your class goes out of scope, the callback factory will not actually cancel the operation, but will rather just skip issuing the callback on your class. This means that if the underlying <code>PPB_UDPSocket</code> resource outlives your class, the browser will still try to write into your buffer when the operation completes. The buffer must be kept valid until then to avoid memory corruption. If you want to release the buffer while the <code><a class="el" href="classpp_1_1_u_d_p_socket.html#a496b1742a9b4ef27d23c9b4b96b9fd0a" title="Receives data from the socket and stores the source address.">RecvFrom()</a></code> call is still pending, you should call <code><a class="el" href="classpp_1_1_u_d_p_socket.html#aa1f03d8d0e7ef59c40724e2691f165f2" title="Cancels all pending reads and writes, and closes the socket.">Close()</a></code> to ensure that the buffer won't be accessed in the future.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[out]</td><td class="paramname">buffer</td><td>The buffer to store the received data on success. It must be at least as large as <code>num_bytes</code>. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">num_bytes</td><td>The number of bytes to receive. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback_with_output.html" title="A CompletionCallbackWithOutput defines a completion callback that additionally stores a pointer to so...">CompletionCallbackWithOutput</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A non-negative number on success to indicate how many bytes have been received; otherwise, an error code from <code>pp_errors.h</code>. </dd></dl>
</div>
</div>
<a class="anchor" id="a657309cd3bc38cf28e25f4c71190d1a0"></a><!-- doxytag: member="pp::UDPSocket::SendTo" ref="a657309cd3bc38cf28e25f4c71190d1a0" args="(const char *buffer, int32_t num_bytes, const NetAddress &amp;addr, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a657309cd3bc38cf28e25f4c71190d1a0">pp::UDPSocket::SendTo</a> </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int32_t&#160;</td>
<td class="paramname"><em>num_bytes</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_net_address.html">NetAddress</a> &amp;&#160;</td>
<td class="paramname"><em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sends data to a specific destination. </p>
<p>The socket must be bound.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">buffer</td><td>The buffer containing the data to send. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">num_bytes</td><td>The number of bytes to send. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code><a class="el" href="classpp_1_1_net_address.html" title="The NetAddress class represents a network address.">NetAddress</a></code> object holding the destination address. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A non-negative number on success to indicate how many bytes have been sent; otherwise, an error code from <code>pp_errors.h</code>. <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have required permissions. <code>PP_ERROR_INPROGRESS</code> will be returned if the socket is busy sending. The caller should wait until a pending send completes before retrying. </dd></dl>
</div>
</div>
<a class="anchor" id="a5ff91fd2342e534b57980c0c2e414251"></a><!-- doxytag: member="pp::UDPSocket::SetOption" ref="a5ff91fd2342e534b57980c0c2e414251" args="(PP_UDPSocket_Option name, const Var &amp;value, const CompletionCallback &amp;callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t <a class="el" href="classpp_1_1_u_d_p_socket.html#a5ff91fd2342e534b57980c0c2e414251">pp::UDPSocket::SetOption</a> </td>
<td>(</td>
<td class="paramtype">PP_UDPSocket_Option&#160;</td>
<td class="paramname"><em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_var.html">Var</a> &amp;&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classpp_1_1_completion_callback.html">CompletionCallback</a> &amp;&#160;</td>
<td class="paramname"><em>callback</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets a socket option on the UDP socket. </p>
<p>Please see the <code>PP_UDPSocket_Option</code> description for option names, value types and allowed values.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">name</td><td>The option to set. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The option value to set. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="classpp_1_1_completion_callback.html" title="This API enables you to implement and receive callbacks when Pepper operations complete asynchronousl...">CompletionCallback</a></code> to be called upon completion.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code>pp_errors.h</code>. </dd></dl>
</div>
</div>
<hr />The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="udp__socket_8h.html">udp_socket.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}