Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

socket_clear_error

Description

Clears the error on the socket or the last error code

Syntax

socket_clear_error(
    ?Socket $socket = null
): void

Parameters

socket

A Socket instance created with socket_create().

Return

No value is returned.

Examples

1 · void

<?

$domain = AF_INET;
$type = SOCK_RDM;
$protocol = 0;

$socket = socket_create($domain, $type, $protocol);

    if($socket === false)
    {
        $error_code = socket_last_error();

        echo $error_code . PHP_EOL;

        socket_clear_error();

        $error_code = socket_last_error();

        die("$error_code");
    }

socket_close($socket);

?>
94
0

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)
    {
        $error_code = socket_last_error($socket);

        echo $error_code . PHP_EOL;

        socket_clear_error($socket);

        $error_code = socket_last_error($socket);

        die("$error_code");
    }

socket_close($socket);

?>
13
0
HomeMenu