Home | History | Annotate | Download | only in c
      1 {{+bindTo:partials.standard_nacl_api}}
      2 <h1>PPB_UDPSocket Struct Reference</h1>
      3 <div id="doxygen-ref">
      4 {{- dummy div to appease doxygen -}}
      5   <div>
      6 <!-- Generated by Doxygen 1.7.6.1 -->
      7 
      8 
      9 </div>
     10 <!--header-->
     11 <div class="contents">
     12 <!-- doxytag: class="PPB_UDPSocket" --><h2>
     13 Data Fields</h2><table class="memberdecls">
     14 
     15 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a48dfac97beb8bef209ea79efaf5b0c32">Create</a> )(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td></tr>
     16 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a90de8c0e342ab04bc6d2439b2e0543a5">IsUDPSocket</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td></tr>
     17 <tr><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a0cae18760f8e9c4f06f160edab542c46">Bind</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
     18 <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#aa71b3888a2edf12c7bccd69d4ddcbbb6">GetBoundAddress</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket)</td></tr>
     19 <tr><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a6f7b8cb60ad4279ac52feba6acca9cc2">RecvFrom</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, char *buffer, int32_t num_bytes, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> *addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
     20 <tr><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a9b78201046b292b6292f0d5bf55d3f76">SendTo</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, const char *buffer, int32_t num_bytes, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
     21 <tr><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a8b34e95d8f1ca113f2c806fb9b64d3e9">Close</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket)</td></tr>
     22 <tr><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a3def770b12177d3fa8faf36e184cc528">SetOption</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, <a class="el" href="group___enums.html#ga1a8472fa3e7150615c45c38fa8c12ce2">PP_UDPSocket_Option</a> name, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> value, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
     23 </table>
     24 <hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
     25 <div class="textblock"><p>The <code>PPB_UDPSocket</code> interface provides UDP socket operations. </p>
     26 <p>Permissions: Apps permission <code>socket</code> with subrule <code>udp-bind</code> is required for <code><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a0cae18760f8e9c4f06f160edab542c46" 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="struct_p_p_b___u_d_p_socket__1__0.html#a9b78201046b292b6292f0d5bf55d3f76" 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>
     27 </div><hr /><h2>Field Documentation</h2>
     28 <a class="anchor" id="a0cae18760f8e9c4f06f160edab542c46"></a><!-- doxytag: member="PPB_UDPSocket::Bind" ref="a0cae18760f8e9c4f06f160edab542c46" args=")(PP_Resource udp_socket, PP_Resource addr, struct PP_CompletionCallback callback)" -->
     29 <div class="memitem">
     30 <div class="memproto">
     31 <table class="memname">
     32 <tr>
     33 <td class="memname">int32_t(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a0cae18760f8e9c4f06f160edab542c46">PPB_UDPSocket::Bind</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
     34 </tr>
     35 </table>
     36 </div>
     37 <div class="memdoc">
     38 <p>Binds the socket to the given address. </p>
     39 <dl class="params"><dt><b>Parameters:</b></dt><dd>
     40 <table class="params">
     41 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket. </td></tr>
     42 <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code>PPB_NetAddress</code> resource. </td></tr>
     43 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> to be called upon completion.</td></tr>
     44 </table>
     45 </dd>
     46 </dl>
     47 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></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>
     48 </div>
     49 </div>
     50 <a class="anchor" id="a8b34e95d8f1ca113f2c806fb9b64d3e9"></a><!-- doxytag: member="PPB_UDPSocket::Close" ref="a8b34e95d8f1ca113f2c806fb9b64d3e9" args=")(PP_Resource udp_socket)" -->
     51 <div class="memitem">
     52 <div class="memproto">
     53 <table class="memname">
     54 <tr>
     55 <td class="memname">void(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a8b34e95d8f1ca113f2c806fb9b64d3e9">PPB_UDPSocket::Close</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket)</td>
     56 </tr>
     57 </table>
     58 </div>
     59 <div class="memdoc">
     60 <p>Cancels all pending reads and writes, and closes the socket. </p>
     61 <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 parameters passed into previous <code><a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a6f7b8cb60ad4279ac52feba6acca9cc2" 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="struct_p_p_b___u_d_p_socket__1__0.html#a0cae18760f8e9c4f06f160edab542c46" title="Binds the socket to the given address.">Bind()</a></code> again.</p>
     62 <p>The socket is implicitly closed if it is destroyed, so you are not required to call this method.</p>
     63 <dl class="params"><dt><b>Parameters:</b></dt><dd>
     64 <table class="params">
     65 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket. </td></tr>
     66 </table>
     67 </dd>
     68 </dl>
     69 </div>
     70 </div>
     71 <a class="anchor" id="a48dfac97beb8bef209ea79efaf5b0c32"></a><!-- doxytag: member="PPB_UDPSocket::Create" ref="a48dfac97beb8bef209ea79efaf5b0c32" args=")(PP_Instance instance)" -->
     72 <div class="memitem">
     73 <div class="memproto">
     74 <table class="memname">
     75 <tr>
     76 <td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a48dfac97beb8bef209ea79efaf5b0c32">PPB_UDPSocket::Create</a>)(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td>
     77 </tr>
     78 </table>
     79 </div>
     80 <div class="memdoc">
     81 <p>Creates a UDP socket resource. </p>
     82 <dl class="params"><dt><b>Parameters:</b></dt><dd>
     83 <table class="params">
     84 <tr><td class="paramdir">[in]</td><td class="paramname">instance</td><td>A <code>PP_Instance</code> identifying one instance of a module.</td></tr>
     85 </table>
     86 </dd>
     87 </dl>
     88 <dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> corresponding to a UDP socket or 0 on failure. </dd></dl>
     89 </div>
     90 </div>
     91 <a class="anchor" id="aa71b3888a2edf12c7bccd69d4ddcbbb6"></a><!-- doxytag: member="PPB_UDPSocket::GetBoundAddress" ref="aa71b3888a2edf12c7bccd69d4ddcbbb6" args=")(PP_Resource udp_socket)" -->
     92 <div class="memitem">
     93 <div class="memproto">
     94 <table class="memname">
     95 <tr>
     96 <td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#aa71b3888a2edf12c7bccd69d4ddcbbb6">PPB_UDPSocket::GetBoundAddress</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket)</td>
     97 </tr>
     98 </table>
     99 </div>
    100 <div class="memdoc">
    101 <p>Gets the address that the socket is bound to. </p>
    102 <p>The socket must be bound.</p>
    103 <dl class="params"><dt><b>Parameters:</b></dt><dd>
    104 <table class="params">
    105 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket.</td></tr>
    106 </table>
    107 </dd>
    108 </dl>
    109 <dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PPB_NetAddress</code> resource on success or 0 on failure. </dd></dl>
    110 </div>
    111 </div>
    112 <a class="anchor" id="a90de8c0e342ab04bc6d2439b2e0543a5"></a><!-- doxytag: member="PPB_UDPSocket::IsUDPSocket" ref="a90de8c0e342ab04bc6d2439b2e0543a5" args=")(PP_Resource resource)" -->
    113 <div class="memitem">
    114 <div class="memproto">
    115 <table class="memname">
    116 <tr>
    117 <td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a90de8c0e342ab04bc6d2439b2e0543a5">PPB_UDPSocket::IsUDPSocket</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td>
    118 </tr>
    119 </table>
    120 </div>
    121 <div class="memdoc">
    122 <p>Determines if a given resource is a UDP socket. </p>
    123 <dl class="params"><dt><b>Parameters:</b></dt><dd>
    124 <table class="params">
    125 <tr><td class="paramdir">[in]</td><td class="paramname">resource</td><td>A <code>PP_Resource</code> to check.</td></tr>
    126 </table>
    127 </dd>
    128 </dl>
    129 <dl class="return"><dt><b>Returns:</b></dt><dd><code>PP_TRUE</code> if the input is a <code>PPB_UDPSocket</code> resource; <code>PP_FALSE</code> otherwise. </dd></dl>
    130 </div>
    131 </div>
    132 <a class="anchor" id="a6f7b8cb60ad4279ac52feba6acca9cc2"></a><!-- doxytag: member="PPB_UDPSocket::RecvFrom" ref="a6f7b8cb60ad4279ac52feba6acca9cc2" args=")(PP_Resource udp_socket, char *buffer, int32_t num_bytes, PP_Resource *addr, struct PP_CompletionCallback callback)" -->
    133 <div class="memitem">
    134 <div class="memproto">
    135 <table class="memname">
    136 <tr>
    137 <td class="memname">int32_t(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a6f7b8cb60ad4279ac52feba6acca9cc2">PPB_UDPSocket::RecvFrom</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, char *buffer, int32_t num_bytes, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> *addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
    138 </tr>
    139 </table>
    140 </div>
    141 <div class="memdoc">
    142 <p>Receives data from the socket and stores the source address. </p>
    143 <p>The socket must be bound.</p>
    144 <dl class="params"><dt><b>Parameters:</b></dt><dd>
    145 <table class="params">
    146 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket. </td></tr>
    147 <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>
    148 <tr><td class="paramdir">[in]</td><td class="paramname">num_bytes</td><td>The number of bytes to receive. </td></tr>
    149 <tr><td class="paramdir">[out]</td><td class="paramname">addr</td><td>A <code>PPB_NetAddress</code> resource to store the source address on success. </td></tr>
    150 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> to be called upon completion.</td></tr>
    151 </table>
    152 </dd>
    153 </dl>
    154 <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><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. </dd></dl>
    155 </div>
    156 </div>
    157 <a class="anchor" id="a9b78201046b292b6292f0d5bf55d3f76"></a><!-- doxytag: member="PPB_UDPSocket::SendTo" ref="a9b78201046b292b6292f0d5bf55d3f76" args=")(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, PP_Resource addr, struct PP_CompletionCallback callback)" -->
    158 <div class="memitem">
    159 <div class="memproto">
    160 <table class="memname">
    161 <tr>
    162 <td class="memname">int32_t(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a9b78201046b292b6292f0d5bf55d3f76">PPB_UDPSocket::SendTo</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, const char *buffer, int32_t num_bytes, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> addr, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
    163 </tr>
    164 </table>
    165 </div>
    166 <div class="memdoc">
    167 <p>Sends data to a specific destination. </p>
    168 <p>The socket must be bound.</p>
    169 <dl class="params"><dt><b>Parameters:</b></dt><dd>
    170 <table class="params">
    171 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket. </td></tr>
    172 <tr><td class="paramdir">[in]</td><td class="paramname">buffer</td><td>The buffer containing the data to send. </td></tr>
    173 <tr><td class="paramdir">[in]</td><td class="paramname">num_bytes</td><td>The number of bytes to send. </td></tr>
    174 <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code>PPB_NetAddress</code> resource holding the destination address. </td></tr>
    175 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> to be called upon completion.</td></tr>
    176 </table>
    177 </dd>
    178 </dl>
    179 <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><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have required permissions. </dd></dl>
    180 </div>
    181 </div>
    182 <a class="anchor" id="a3def770b12177d3fa8faf36e184cc528"></a><!-- doxytag: member="PPB_UDPSocket::SetOption" ref="a3def770b12177d3fa8faf36e184cc528" args=")(PP_Resource udp_socket, PP_UDPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback)" -->
    183 <div class="memitem">
    184 <div class="memproto">
    185 <table class="memname">
    186 <tr>
    187 <td class="memname">int32_t(* <a class="el" href="struct_p_p_b___u_d_p_socket__1__0.html#a3def770b12177d3fa8faf36e184cc528">PPB_UDPSocket::SetOption</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> udp_socket, <a class="el" href="group___enums.html#ga1a8472fa3e7150615c45c38fa8c12ce2">PP_UDPSocket_Option</a> name, struct <a class="el" href="struct_p_p___var.html">PP_Var</a> value, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
    188 </tr>
    189 </table>
    190 </div>
    191 <div class="memdoc">
    192 <p>Sets a socket option on the UDP socket. </p>
    193 <p>Please see the <code>PP_UDPSocket_Option</code> description for option names, value types and allowed values.</p>
    194 <dl class="params"><dt><b>Parameters:</b></dt><dd>
    195 <table class="params">
    196 <tr><td class="paramdir">[in]</td><td class="paramname">udp_socket</td><td>A <code>PP_Resource</code> corresponding to a UDP socket. </td></tr>
    197 <tr><td class="paramdir">[in]</td><td class="paramname">name</td><td>The option to set. </td></tr>
    198 <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The option value to set. </td></tr>
    199 <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>A <code><a class="el" href="struct_p_p___completion_callback.html" title="PP_CompletionCallback is a common mechanism for supporting potentially asynchronous calls in browser ...">PP_CompletionCallback</a></code> to be called upon completion.</td></tr>
    200 </table>
    201 </dd>
    202 </dl>
    203 <dl class="return"><dt><b>Returns:</b></dt><dd>An int32_t containing an error code from <code><a class="el" href="pp__errors_8h.html" title="This file defines an enumeration of all PPAPI error codes.">pp_errors.h</a></code>. </dd></dl>
    204 </div>
    205 </div>
    206 <hr />The documentation for this struct was generated from the following file:<ul>
    207 <li><a class="el" href="ppb__udp__socket_8h.html">ppb_udp_socket.h</a></li>
    208 </ul>
    209 </div><!-- contents -->
    210 </div>
    211 {{/partials.standard_nacl_api}}
    212