PHP » socket_last_error
If a socket resource is passed to this function, the last error which occurred on this particular socket is returned. If the socket resource is omitted, the error code of the last failed socket functi
socket_last_error() does not clear the error code, use socket_clear_error() for this purpose.
| Parameters | Description |
|---|---|
| socket | A valid socket resource created with socket_create(). |
Return Value: This function returns a socket error code.
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");
}
?>


