blob: 7b0a919edbfbb599ada584541b47fa9b47b7476e [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__2.html#a889fb7b3263304ef5057cd541a197312">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__2.html#a5355f00c99cd7fb9563eb9987a73a3c5">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__2.html#aeb78a27cd902e93c557a0015812237f9">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__2.html#ad107b3d5541072b14e2b8acc836b3939">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__2.html#a5916aca75506efccaa2905bb758421a2">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__2.html#abb362a218eef33522ea9b508d482a015">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__2.html#aac72febd03fe6e6e5adafcfd2b24a8b1">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__2.html#ac798b76c497f00231bd592ebdb584042">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__2.html#acffd2f5faddf094ccd9638128167259d">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__2.html#ad9b1525032df05cf446f7d7c27c6145a">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__2.html#a6ca1887389cfaf357054e016adf7fc77">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__2.html#aa42176651e65cf589fc310c0b2ed5751">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__2.html#ad107b3d5541072b14e2b8acc836b3939" 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__2.html#acffd2f5faddf094ccd9638128167259d" 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="ad9b1525032df05cf446f7d7c27c6145a"></a><!-- doxytag: member="PPB_TCPSocket::Accept" ref="ad9b1525032df05cf446f7d7c27c6145a" 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__2.html#ad9b1525032df05cf446f7d7c27c6145a">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="aeb78a27cd902e93c557a0015812237f9"></a><!-- doxytag: member="PPB_TCPSocket::Bind" ref="aeb78a27cd902e93c557a0015812237f9" 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__2.html#aeb78a27cd902e93c557a0015812237f9">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="a6ca1887389cfaf357054e016adf7fc77"></a><!-- doxytag: member="PPB_TCPSocket::Close" ref="a6ca1887389cfaf357054e016adf7fc77" 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__2.html#a6ca1887389cfaf357054e016adf7fc77">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__2.html#aac72febd03fe6e6e5adafcfd2b24a8b1" title="Reads data from the socket.">Read()</a></code> or <code><a class="el" href="struct_p_p_b___t_c_p_socket__1__2.html#ad9b1525032df05cf446f7d7c27c6145a" 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__2.html#ad107b3d5541072b14e2b8acc836b3939" 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__2.html#acffd2f5faddf094ccd9638128167259d" 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="ad107b3d5541072b14e2b8acc836b3939"></a><!-- doxytag: member="PPB_TCPSocket::Connect" ref="ad107b3d5541072b14e2b8acc836b3939" 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__2.html#ad107b3d5541072b14e2b8acc836b3939">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__2.html#ad107b3d5541072b14e2b8acc836b3939" 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="a889fb7b3263304ef5057cd541a197312"></a><!-- doxytag: member="PPB_TCPSocket::Create" ref="a889fb7b3263304ef5057cd541a197312" 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__2.html#a889fb7b3263304ef5057cd541a197312">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="a5916aca75506efccaa2905bb758421a2"></a><!-- doxytag: member="PPB_TCPSocket::GetLocalAddress" ref="a5916aca75506efccaa2905bb758421a2" 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__2.html#a5916aca75506efccaa2905bb758421a2">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="abb362a218eef33522ea9b508d482a015"></a><!-- doxytag: member="PPB_TCPSocket::GetRemoteAddress" ref="abb362a218eef33522ea9b508d482a015" 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__2.html#abb362a218eef33522ea9b508d482a015">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="a5355f00c99cd7fb9563eb9987a73a3c5"></a><!-- doxytag: member="PPB_TCPSocket::IsTCPSocket" ref="a5355f00c99cd7fb9563eb9987a73a3c5" 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__2.html#a5355f00c99cd7fb9563eb9987a73a3c5">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="acffd2f5faddf094ccd9638128167259d"></a><!-- doxytag: member="PPB_TCPSocket::Listen" ref="acffd2f5faddf094ccd9638128167259d" 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__2.html#acffd2f5faddf094ccd9638128167259d">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="aac72febd03fe6e6e5adafcfd2b24a8b1"></a><!-- doxytag: member="PPB_TCPSocket::Read" ref="aac72febd03fe6e6e5adafcfd2b24a8b1" 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__2.html#aac72febd03fe6e6e5adafcfd2b24a8b1">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="aa42176651e65cf589fc310c0b2ed5751"></a><!-- doxytag: member="PPB_TCPSocket::SetOption" ref="aa42176651e65cf589fc310c0b2ed5751" 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__2.html#aa42176651e65cf589fc310c0b2ed5751">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="ac798b76c497f00231bd592ebdb584042"></a><!-- doxytag: member="PPB_TCPSocket::Write" ref="ac798b76c497f00231bd592ebdb584042" 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__2.html#ac798b76c497f00231bd592ebdb584042">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}}