socket_last_error
socket_last_error
Returns the last error on the socket
int **socket_last_error** $socket
If a instance is passed to this function, the last error which
occurred on this particular socket is returned. If is
null, the error code of the last failed socket function is returned.
The latter is particularly helpful for functions like
which don't return a socket on
failure and which can fail for reasons
not directly tied to a particular socket. The error code is suitable to
be fed to which returns a string
describing the given error code.
Socket``socket``socket_create``socket_select``socket_strerror
If no error had occurred, or the error had been cleared with
, the function returns .
socket_clear_error``0
socket
A instance created with .
Socket``socket_create
This function returns a socket error code.
Voorbeeld: example
<?php
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Couldn't create socket: [$errorcode] $errormsg");
}
?>
Opmerking: > does not clear the error code, use for this purpose.
socket_last_error``socket_clear_error