<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Accept a connection on a socket created by stream_socket_server</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-write-buffer.html">stream_set_write_buffer</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-client.html">stream_socket_client</a></div> <div class="up"><a href="ref.stream.html">Stream Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.stream-socket-accept" class="refentry"> <div class="refnamediv"> <h1 class="refname">stream_socket_accept</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">stream_socket_accept</span> — <span class="dc-title">Accept a connection on a socket created by <span class="function"><a href="function.stream-socket-server.html" class="function">stream_socket_server()</a></span></span></p> </div> <div class="refsect1 description" id="refsect1-function.stream-socket-accept-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>stream_socket_accept</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$server_socket</code></span> [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$timeout</code><span class="initializer"> = ini_get("default_socket_timeout")</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$peername</code></span> ]] )</div> <p class="para rdfs-comment"> Accept a connection on a socket previously created by <span class="function"><a href="function.stream-socket-server.html" class="function">stream_socket_server()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.stream-socket-accept-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">server_socket</code></em></span> <dd> <p class="para"> The server socket to accept a connection from. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">timeout</code></em></span> <dd> <p class="para"> Override the default socket accept timeout. Time should be given in seconds. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">peername</code></em></span> <dd> <p class="para"> Will be set to the name (address) of the client which connected, if included and available from the selected transport. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Can also be determined later using <span class="function"><a href="function.stream-socket-get-name.html" class="function">stream_socket_get_name()</a></span>. </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.stream-socket-accept-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a stream to the accepted socket connection or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 notes" id="refsect1-function.stream-socket-accept-notes"> <h3 class="title">Notes</h3> <div class="warning"><strong class="warning">Warning</strong> <p class="para"> This function should not be used with UDP server sockets. Instead, use <span class="function"><a href="function.stream-socket-recvfrom.html" class="function">stream_socket_recvfrom()</a></span> and <span class="function"><a href="function.stream-socket-sendto.html" class="function">stream_socket_sendto()</a></span>. </p> </div> </div> <div class="refsect1 seealso" id="refsect1-function.stream-socket-accept-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.stream-socket-server.html" class="function" rel="rdfs-seeAlso">stream_socket_server()</a> - Create an Internet or Unix domain server socket</span></li> <li class="member"> <span class="function"><a href="function.stream-socket-get-name.html" class="function" rel="rdfs-seeAlso">stream_socket_get_name()</a> - Retrieve the name of the local or remote sockets</span></li> <li class="member"> <span class="function"><a href="function.stream-set-blocking.html" class="function" rel="rdfs-seeAlso">stream_set_blocking()</a> - Set blocking/non-blocking mode on a stream</span></li> <li class="member"> <span class="function"><a href="function.stream-set-timeout.html" class="function" rel="rdfs-seeAlso">stream_set_timeout()</a> - Set timeout period on a stream</span></li> <li class="member"> <span class="function"><a href="function.fgets.html" class="function" rel="rdfs-seeAlso">fgets()</a> - Gets line from file pointer</span></li> <li class="member"> <span class="function"><a href="function.fgetss.html" class="function" rel="rdfs-seeAlso">fgetss()</a> - Gets line from file pointer and strip HTML tags</span></li> <li class="member"> <span class="function"><a href="function.fwrite.html" class="function" rel="rdfs-seeAlso">fwrite()</a> - Binary-safe file write</span></li> <li class="member"> <span class="function"><a href="function.fclose.html" class="function" rel="rdfs-seeAlso">fclose()</a> - Closes an open file pointer</span></li> <li class="member"> <span class="function"><a href="function.feof.html" class="function" rel="rdfs-seeAlso">feof()</a> - Tests for end-of-file on a file pointer</span></li> <li class="member"><a href="ref.curl.html" class="xref">cURL Functions</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-write-buffer.html">stream_set_write_buffer</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-client.html">stream_socket_client</a></div> <div class="up"><a href="ref.stream.html">Stream Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>