Handling socket errors
suggest changesocket_last_error
can be used to get the error ID of the last error from the sockets extension.
socket_strerror
can be used to convert the ID to human-readable strings.
function onSocketFailure(string $message, $socket = null) {
if(is_resource($socket)) {
$message .= ": " . socket_strerror(socket_last_error($socket));
}
die($message);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents