socket_last_error
Description
The socket_last_error of Sockets for PHP returns the last error on the socket.
Syntax
socket_last_error( ?Socket $socket = null ): int
Parameters
socket
A Socket instance created with socket_create().
Return
Returns a socket error code.
Examples
1 · void
<? $domain = AF_INET; $type = SOCK_RDM; $protocol = 0; $socket = socket_create($domain, $type, $protocol); if($socket === false) { $return = socket_last_error(); die("$return"); } socket_close($socket); ?>
94
2 · socket
<? $domain = AF_INET; $type = SOCK_STREAM; $protocol = SOL_TCP; $socket = socket_create($domain, $type, $protocol); $address = '127.0.0.1'; $port = 80; $socket_bind = socket_bind($socket, $address, $port); if($socket_bind === false) { $return = socket_last_error($socket); die("$return"); } socket_close($socket); ?>
13
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_listen
- socket_create_pair
- socket_export_stream
- socket_get_option
- socket_getopt
- socket_getpeername
- socket_getsockname
- socket_import_stream
- 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