socket_create_listen
Description
The socket_create_listen of Sockets for PHP opens a socket on port to accept connections.
Syntax
socket_create_listen( int $port, int $backlog = 128 ): Socket|false
Parameters
port
The port on which to listen on all interfaces.
backlog
The backlog parameter defines the maximum length the queue of pending connections may grow to. SOMAXCONN may be passed as backlog parameter, see socket_listen() for more information.
Return
Returns a new Socket instance on success or false on error.
The error code can be retrieved with socket_last_error(). This code may be passed to socket_strerror() to get a textual explanation of the error.
Examples
1 · port
<? $port = 5000; $return = socket_create_listen($port); if($return === false) { $error_code = socket_last_error(); $socket_strerror = socket_strerror($error_code); die("socket_create_listen: $socket_strerror"); } var_export($return); socket_close($return);
\Socket::__set_state(array( ))
2 · backlog
<? $port = 5000; $backlog = 1; $return = socket_create_listen($port, $backlog); if($return === false) { $error_code = socket_last_error(); $socket_strerror = socket_strerror($error_code); die("socket_create_listen: $socket_strerror"); } var_export($return); socket_close($return);
\Socket::__set_state(array( ))
Links
Sockets
- socket_accept
- socket_addrinfo_bind
- socket_addrinfo_connect
- socket_addrinfo_explain
- socket_addrinfo_lookup
- socket_atmark
- socket_bind
- socket_clear_error
- socket_close
- socket_cmsg_space
- socket_connect
- socket_create
- socket_create_pair
- socket_export_stream
- socket_get_option
- socket_getopt
- socket_getpeername
- socket_getsockname
- socket_import_stream
- socket_last_error
- socket_listen
- socket_read
- socket_recv
- socket_recvfrom
- socket_recvmsg
- socket_select
- socket_send
- socket_sendmsg
- socket_sendto
- socket_set_block
- socket_set_nonblock
- socket_set_option
- socket_setopt
- socket_shutdown
- socket_strerror
- socket_write
- socket_wsaprotocol_info_export
- socket_wsaprotocol_info_import
- socket_wsaprotocol_info_release