Handling socket errors

suggest change

socket_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);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents