SocketError
+ Inheritance diagram for SocketError:

Description

A socket error.

See also
https://php.net/sockets.constants

Protected Properties

mixed $extra
 Extra data, if any. More...
 

Public Static Methods

static int getLast ($resource=null)
 Retrieves and clears the socket error. More...
 

Public Methods

 __construct ($subject=null, $fallback=0, SocketError $previous=null)
 Initializes the error based on a mixed subject. More...
 
mixed getExtra ()
 
$this setExtra ($extra)
 

Properties

◆ $extra

mixed $extra
protected

Extra data, if any.

The specific contents are documented where the error is thrown.

Constructor

◆ __construct()

__construct (   $subject = null,
  $fallback = 0,
SocketError  $previous = null 
)

Initializes the error based on a mixed subject.

PHP's core socket functions like to return false without setting errno in some places.

To account for that scenario, a fallback code can be given.

When the fallback code is used, PHP's last suppressed warning message is used.

All scenarios within this library have been meticulously cross-checked with the PHP C source code for cases where a fallback code is necessary.

Parameters
int | resource | null$subjectError constant, resource to check, or NULL to use the global socket error.
int$fallbackCode to assume if one can't be found via the subject.
SocketError | null$previousSlippage of a prior error.

Methods

◆ getExtra()

mixed getExtra ( )
Returns
mixed

◆ getLast()

static int getLast (   $resource = null)
static

Retrieves and clears the socket error.

For resources, this favors SO_ERROR, then falls back to the error number set by PHP. Both error codes are cleared.

See also
https://php.net/socket_last_error
https://php.net/socket_clear_error
Parameters
resource$resourcePHP socket resource, or null for the global error.
Returns
int If the resource is closed or not a socket, SOCKET_EBADF is returned.

◆ setExtra()

$this setExtra (   $extra)
Parameters
mixed$extra
Returns
$this