<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.remote.other.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'book.sockets.php',
    1 => 'Sockets',
    2 => 'Sockets',
  ),
  'up' => 
  array (
    0 => 'refs.remote.other.php',
    1 => 'Other Services',
  ),
  'prev' => 
  array (
    0 => 'class.snmpexception.php',
    1 => 'SNMPException',
  ),
  'next' => 
  array (
    0 => 'sockets.setup.php',
    1 => 'Installing/Configuring',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sockets/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.sockets.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.sockets" class="book">
 
 <h1 class="title">Sockets</h1>
 
 
 <div id="intro.sockets" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="para">
   The socket extension implements a low-level interface to the socket
   communication functions based on the popular BSD sockets, providing the
   possibility to act as a socket server as well as a client.
  </p>
  <p class="para">
   For a more generic client-side socket interface, see
   <span class="function"><a href="function.stream-socket-client.php" class="function">stream_socket_client()</a></span>, 
   <span class="function"><a href="function.stream-socket-server.php" class="function">stream_socket_server()</a></span>,
   <span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span>, and
   <span class="function"><a href="function.pfsockopen.php" class="function">pfsockopen()</a></span>.
  </p>
  <p class="para">
   When using these functions, it is important to remember that while
   many of them have identical names to their C counterparts, they
   often have different declarations. Please be sure to read the
   descriptions to avoid confusion.
  </p>
  <p class="para">
   Those unfamiliar with socket programming can find a lot
   of useful material in the appropriate Unix man pages, and there is a great
   deal of tutorial information on socket programming in C on the web, much
   of which can be applied, with slight modifications, to socket programming
   in PHP. The <a href="http://www.unixguide.net/network/socketfaq/" class="link external">&raquo;&nbsp;Unix Socket
   FAQ</a> might be a good start.
  </p>
 </div>
 
 
 







 




 







 






 






 




 





<ul class="chunklist chunklist_book"><li><a href="sockets.setup.php">Installing/Configuring</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="sockets.installation.php">Installation</a></li><li><a href="sockets.resources.php">Resource Types</a></li></ul></li><li><a href="sockets.constants.php">Predefined Constants</a></li><li><a href="sockets.examples.php">Examples</a></li><li><a href="sockets.errors.php">Socket Errors</a></li><li><a href="ref.sockets.php">Socket Functions</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.socket-accept.php">socket_accept</a> — Accepts a connection on a socket</li><li><a href="function.socket-addrinfo-bind.php">socket_addrinfo_bind</a> — Create and bind to a socket from a given addrinfo</li><li><a href="function.socket-addrinfo-connect.php">socket_addrinfo_connect</a> — Create and connect to a socket from a given addrinfo</li><li><a href="function.socket-addrinfo-explain.php">socket_addrinfo_explain</a> — Get information about addrinfo</li><li><a href="function.socket-addrinfo-lookup.php">socket_addrinfo_lookup</a> — Get array with contents of getaddrinfo about the given hostname</li><li><a href="function.socket-atmark.php">socket_atmark</a> — Determines whether socket is at out-of-band mark</li><li><a href="function.socket-bind.php">socket_bind</a> — Binds a name to a socket</li><li><a href="function.socket-clear-error.php">socket_clear_error</a> — Clears the error on the socket or the last error code</li><li><a href="function.socket-close.php">socket_close</a> — Closes a Socket instance</li><li><a href="function.socket-cmsg-space.php">socket_cmsg_space</a> — Calculate message buffer size</li><li><a href="function.socket-connect.php">socket_connect</a> — Initiates a connection on a socket</li><li><a href="function.socket-create.php">socket_create</a> — Create a socket (endpoint for communication)</li><li><a href="function.socket-create-listen.php">socket_create_listen</a> — Opens a socket on port to accept connections</li><li><a href="function.socket-create-pair.php">socket_create_pair</a> — Creates a pair of indistinguishable sockets and stores them in an array</li><li><a href="function.socket-export-stream.php">socket_export_stream</a> — Export a socket into a stream that encapsulates a socket</li><li><a href="function.socket-get-option.php">socket_get_option</a> — Gets socket options for the socket</li><li><a href="function.socket-getopt.php">socket_getopt</a> — Alias of socket_get_option</li><li><a href="function.socket-getpeername.php">socket_getpeername</a> — Queries the remote side of the given socket</li><li><a href="function.socket-getsockname.php">socket_getsockname</a> — Queries the local side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on its type</li><li><a href="function.socket-import-stream.php">socket_import_stream</a> — Import a stream</li><li><a href="function.socket-last-error.php">socket_last_error</a> — Returns the last error on the socket</li><li><a href="function.socket-listen.php">socket_listen</a> — Listens for a connection on a socket</li><li><a href="function.socket-read.php">socket_read</a> — Reads a maximum of length bytes from a socket</li><li><a href="function.socket-recv.php">socket_recv</a> — Receives data from a connected socket</li><li><a href="function.socket-recvfrom.php">socket_recvfrom</a> — Receives data from a socket whether or not it is connection-oriented</li><li><a href="function.socket-recvmsg.php">socket_recvmsg</a> — Read a message</li><li><a href="function.socket-select.php">socket_select</a> — Runs the select() system call on the given arrays of sockets with a specified timeout</li><li><a href="function.socket-send.php">socket_send</a> — Sends data to a connected socket</li><li><a href="function.socket-sendmsg.php">socket_sendmsg</a> — Send a message</li><li><a href="function.socket-sendto.php">socket_sendto</a> — Sends a message to a socket, whether it is connected or not</li><li><a href="function.socket-set-block.php">socket_set_block</a> — Sets blocking mode on a socket</li><li><a href="function.socket-set-nonblock.php">socket_set_nonblock</a> — Sets nonblocking mode for file descriptor fd</li><li><a href="function.socket-set-option.php">socket_set_option</a> — Sets socket options for the socket</li><li><a href="function.socket-setopt.php">socket_setopt</a> — Alias of socket_set_option</li><li><a href="function.socket-shutdown.php">socket_shutdown</a> — Shuts down a socket for receiving, sending, or both</li><li><a href="function.socket-strerror.php">socket_strerror</a> — Return a string describing a socket error</li><li><a href="function.socket-write.php">socket_write</a> — Write to a socket</li><li><a href="function.socket-wsaprotocol-info-export.php">socket_wsaprotocol_info_export</a> — Exports the WSAPROTOCOL_INFO Structure</li><li><a href="function.socket-wsaprotocol-info-import.php">socket_wsaprotocol_info_import</a> — Imports a Socket from another Process</li><li><a href="function.socket-wsaprotocol-info-release.php">socket_wsaprotocol_info_release</a> — Releases an exported WSAPROTOCOL_INFO Structure</li></ul></li><li><a href="class.socket.php">Socket</a> — The Socket class</li><li><a href="class.addressinfo.php">AddressInfo</a> — The AddressInfo class</li></ul></div><?php manual_footer($setup); ?>