blob: d9d5a0d298380a82175b09b919eb575db0dfa173 [file] [log] [blame]
{{+bindTo:partials.standard_nacl_api}}
<h1>PPB_TCPSocket Struct 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="PPB_TCPSocket" --><h2>
Data Fields</h2><table class="memberdecls">
<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___t_c_p_socket__1__1.html#a615cb349fbe99e25ae09078091c87b43">Create</a> )(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td></tr>
<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___t_c_p_socket__1__1.html#afe32ae060181370e12c93c206964a58f">IsTCPSocket</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td></tr>
<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___t_c_p_socket__1__1.html#aae9a2f9ced445ca28a21721a0df5c567">Bind</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_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>
<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___t_c_p_socket__1__1.html#a1d12313b4681e48fa6f9b789d26414cb">Connect</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_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>
<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___t_c_p_socket__1__1.html#ab64edd222b040500767f5c9182358b68">GetLocalAddress</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td></tr>
<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___t_c_p_socket__1__1.html#af28b600fcdf657ca31dd2e9218a774e1">GetRemoteAddress</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td></tr>
<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___t_c_p_socket__1__1.html#ab4bd707da2d9d2136c59a08b3de2ce32">Read</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, char *buffer, int32_t bytes_to_read, struct <a class="el" href="struct_p_p___completion_callback.html">PP_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="struct_p_p_b___t_c_p_socket__1__1.html#adea2cbc4e8487f2f26c2126983f9c856">Write</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, const char *buffer, int32_t bytes_to_write, struct <a class="el" href="struct_p_p___completion_callback.html">PP_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="struct_p_p_b___t_c_p_socket__1__1.html#af3b28d2bf3f44d89e434e158854bea69">Listen</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, int32_t backlog, struct <a class="el" href="struct_p_p___completion_callback.html">PP_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="struct_p_p_b___t_c_p_socket__1__1.html#a444d931c7fbb40e47cca8c55d57250f7">Accept</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> *accepted_tcp_socket, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#afc2d9d7577df96bd0ac8f3cc6f503266">Close</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td></tr>
<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___t_c_p_socket__1__1.html#ab64ed8f1f7b4c3dce8d3493fb894ea0d">SetOption</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, <a class="el" href="group___enums.html#ga1557c0bbce8739a3418e6027a9c44e12">PP_TCPSocket_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>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>The <code>PPB_TCPSocket</code> interface provides TCP socket operations. </p>
<p>Permissions: Apps permission <code>socket</code> with subrule <code>tcp-connect</code> is required for <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a1d12313b4681e48fa6f9b789d26414cb" title="Connects the socket to the given address.">Connect()</a></code>; subrule <code>tcp-listen</code> is required for <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#af3b28d2bf3f44d89e434e158854bea69" title="Starts listening.">Listen()</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>Field Documentation</h2>
<a class="anchor" id="a444d931c7fbb40e47cca8c55d57250f7"></a><!-- doxytag: member="PPB_TCPSocket::Accept" ref="a444d931c7fbb40e47cca8c55d57250f7" args=")(PP_Resource tcp_socket, PP_Resource *accepted_tcp_socket, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a444d931c7fbb40e47cca8c55d57250f7">PPB_TCPSocket::Accept</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, <a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> *accepted_tcp_socket, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Accepts a connection. </p>
<p>The socket must be listening.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">accepted_tcp_socket</td><td>Stores the accepted TCP socket on success. </td></tr>
<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>
</table>
</dd>
</dl>
<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>, including (but not limited to):<ul>
<li><code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted. </li>
</ul>
</dd></dl>
</div>
</div>
<a class="anchor" id="aae9a2f9ced445ca28a21721a0df5c567"></a><!-- doxytag: member="PPB_TCPSocket::Bind" ref="aae9a2f9ced445ca28a21721a0df5c567" args=")(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#aae9a2f9ced445ca28a21721a0df5c567">PPB_TCPSocket::Bind</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_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>
</table>
</div>
<div class="memdoc">
<p>Binds the socket to the given address. </p>
<p>The socket must not be bound.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code>PPB_NetAddress</code> resource. </td></tr>
<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>
</table>
</dd>
</dl>
<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>, including (but not limited to):<ul>
<li><code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use.</li>
<li><code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid. </li>
</ul>
</dd></dl>
</div>
</div>
<a class="anchor" id="afc2d9d7577df96bd0ac8f3cc6f503266"></a><!-- doxytag: member="PPB_TCPSocket::Close" ref="afc2d9d7577df96bd0ac8f3cc6f503266" args=")(PP_Resource tcp_socket)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#afc2d9d7577df96bd0ac8f3cc6f503266">PPB_TCPSocket::Close</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Cancels all pending operations 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 buffer pointers passed into previous <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#ab4bd707da2d9d2136c59a08b3de2ce32" title="Reads data from the socket.">Read()</a></code> or <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a444d931c7fbb40e47cca8c55d57250f7" title="Accepts a connection.">Accept()</a></code> calls will be accessed. It is not valid to call <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a1d12313b4681e48fa6f9b789d26414cb" title="Connects the socket to the given address.">Connect()</a></code> or <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#af3b28d2bf3f44d89e434e158854bea69" title="Starts listening.">Listen()</a></code> again.</p>
<p>The socket is implicitly closed if it is destroyed, so you are not required to call this method.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a1d12313b4681e48fa6f9b789d26414cb"></a><!-- doxytag: member="PPB_TCPSocket::Connect" ref="a1d12313b4681e48fa6f9b789d26414cb" args=")(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a1d12313b4681e48fa6f9b789d26414cb">PPB_TCPSocket::Connect</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_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>
</table>
</div>
<div class="memdoc">
<p>Connects the socket to the given address. </p>
<p>The socket must not be listening. Binding the socket beforehand is optional.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>A <code>PPB_NetAddress</code> resource. </td></tr>
<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>
</table>
</dd>
</dl>
<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>, including (but not limited to):<ul>
<li><code>PP_ERROR_NOACCESS</code>: the caller doesn't have required permissions.</li>
<li><code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is unreachable.</li>
<li><code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was refused.</li>
<li><code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed.</li>
<li><code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed out.</li>
</ul>
</dd></dl>
<p>Since version 1.1, if the socket is listening/connected or has a pending listen/connect request, <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a1d12313b4681e48fa6f9b789d26414cb" title="Connects the socket to the given address.">Connect()</a></code> will fail without starting a connection attempt; otherwise, any failure during the connection attempt will cause the socket to be closed. </p>
</div>
</div>
<a class="anchor" id="a615cb349fbe99e25ae09078091c87b43"></a><!-- doxytag: member="PPB_TCPSocket::Create" ref="a615cb349fbe99e25ae09078091c87b43" args=")(PP_Instance instance)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#a615cb349fbe99e25ae09078091c87b43">PPB_TCPSocket::Create</a>)(<a class="el" href="group___typedefs.html#ga89b662403e6a687bb914b80114c0d19d">PP_Instance</a> instance)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates a TCP socket resource. </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>A <code>PP_Instance</code> identifying one instance of a module.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> corresponding to a TCP socket or 0 on failure. </dd></dl>
</div>
</div>
<a class="anchor" id="ab64edd222b040500767f5c9182358b68"></a><!-- doxytag: member="PPB_TCPSocket::GetLocalAddress" ref="ab64edd222b040500767f5c9182358b68" args=")(PP_Resource tcp_socket)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#ab64edd222b040500767f5c9182358b68">PPB_TCPSocket::GetLocalAddress</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Gets the local address of the socket, if it is bound. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PPB_NetAddress</code> resource on success or 0 on failure. </dd></dl>
</div>
</div>
<a class="anchor" id="af28b600fcdf657ca31dd2e9218a774e1"></a><!-- doxytag: member="PPB_TCPSocket::GetRemoteAddress" ref="af28b600fcdf657ca31dd2e9218a774e1" args=")(PP_Resource tcp_socket)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#af28b600fcdf657ca31dd2e9218a774e1">PPB_TCPSocket::GetRemoteAddress</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Gets the remote address of the socket, if it is connected. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PPB_NetAddress</code> resource on success or 0 on failure. </dd></dl>
</div>
</div>
<a class="anchor" id="afe32ae060181370e12c93c206964a58f"></a><!-- doxytag: member="PPB_TCPSocket::IsTCPSocket" ref="afe32ae060181370e12c93c206964a58f" args=")(PP_Resource resource)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#afe32ae060181370e12c93c206964a58f">PPB_TCPSocket::IsTCPSocket</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Determines if a given resource is a TCP socket. </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>PP_Resource</code> to check.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><code>PP_TRUE</code> if the input is a <code>PPB_TCPSocket</code> resource; <code>PP_FALSE</code> otherwise. </dd></dl>
</div>
</div>
<a class="anchor" id="af3b28d2bf3f44d89e434e158854bea69"></a><!-- doxytag: member="PPB_TCPSocket::Listen" ref="af3b28d2bf3f44d89e434e158854bea69" args=")(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#af3b28d2bf3f44d89e434e158854bea69">PPB_TCPSocket::Listen</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, int32_t backlog, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Starts listening. </p>
<p>The socket must be bound and not connected.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">backlog</td><td>A hint to determine the maximum length to which the queue of pending connections may grow. </td></tr>
<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>
</table>
</dd>
</dl>
<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>, including (but not limited to):<ul>
<li><code>PP_ERROR_NOACCESS</code>: the caller doesn't have required permissions.</li>
<li><code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already listening on the same port. </li>
</ul>
</dd></dl>
</div>
</div>
<a class="anchor" id="ab4bd707da2d9d2136c59a08b3de2ce32"></a><!-- doxytag: member="PPB_TCPSocket::Read" ref="ab4bd707da2d9d2136c59a08b3de2ce32" args=")(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#ab4bd707da2d9d2136c59a08b3de2ce32">PPB_TCPSocket::Read</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, char *buffer, int32_t bytes_to_read, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Reads data from the socket. </p>
<p>The socket must be connected. It may perform a partial read.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<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>bytes_to_read</code>. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">bytes_to_read</td><td>The number of bytes to read. </td></tr>
<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>
</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 read, 0 means that end-of-file was reached; 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>
</div>
</div>
<a class="anchor" id="ab64ed8f1f7b4c3dce8d3493fb894ea0d"></a><!-- doxytag: member="PPB_TCPSocket::SetOption" ref="ab64ed8f1f7b4c3dce8d3493fb894ea0d" args=")(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#ab64ed8f1f7b4c3dce8d3493fb894ea0d">PPB_TCPSocket::SetOption</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, <a class="el" href="group___enums.html#ga1557c0bbce8739a3418e6027a9c44e12">PP_TCPSocket_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>
</table>
</div>
<div class="memdoc">
<p>Sets a socket option on the TCP socket. </p>
<p>Please see the <code>PP_TCPSocket_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">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<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="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>
</table>
</dd>
</dl>
<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>
</div>
</div>
<a class="anchor" id="adea2cbc4e8487f2f26c2126983f9c856"></a><!-- doxytag: member="PPB_TCPSocket::Write" ref="adea2cbc4e8487f2f26c2126983f9c856" args=")(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* <a class="el" href="struct_p_p_b___t_c_p_socket__1__1.html#adea2cbc4e8487f2f26c2126983f9c856">PPB_TCPSocket::Write</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> tcp_socket, const char *buffer, int32_t bytes_to_write, struct <a class="el" href="struct_p_p___completion_callback.html">PP_CompletionCallback</a> callback)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Writes data to the socket. </p>
<p>The socket must be connected. It may perform a partial write.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">tcp_socket</td><td>A <code>PP_Resource</code> corresponding to a TCP socket. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">buffer</td><td>The buffer containing the data to write. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">bytes_to_write</td><td>The number of bytes to write. </td></tr>
<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>
</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 written; 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>
</div>
</div>
<hr />The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="ppb__tcp__socket_8h.html">ppb_tcp_socket.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}