Properties

$protocol

$protocol : \Workerman\Protocols\ProtocolInterface

Application layer protocol.

The format is like this Workerman\Protocols\Http.

Type

ProtocolInterface

$transport

$transport : string

Transport layer protocol.

Type

string

$statistics

$statistics : array

Statistics for status command.

Type

array

$onMessage

$onMessage : callable

Emitted when data is received.

Type

callable

$onClose

$onClose : callable

Emitted when socket connection closed.

Type

callable

$onError

$onError : callable

Emitted when an error occurs with connection.

Type

callable

$onConnect

$onConnect : callable

Emitted when socket connection is successfully established.

Type

callable

$_socket

$_socket : resource

Udp socket.

Type

resource

$_remoteAddress

$_remoteAddress : string

Remote address.

Type

string

$connected

$connected : bool

Connected or not.

Type

bool

$_contextOption

$_contextOption : array

Context option.

Type

array

Methods

__construct()

__construct(string  $remote_address, mixed  $context_option = null) : mixed

Construct.

Parameters

string $remote_address
mixed $context_option

Throws

\Exception

Returns

mixed —

send()

send(string  $send_buffer, bool  $raw = false) : void|bool

Sends data on the connection.

Parameters

string $send_buffer
bool $raw

Returns

void|bool —

getRemoteIp()

getRemoteIp() : string

Get remote IP.

Returns

string —

getRemotePort()

getRemotePort() : int

Get remote port.

Returns

int —

getRemoteAddress()

getRemoteAddress() : string

Get remote address.

Returns

string —

getLocalIp()

getLocalIp() : string

Get local IP.

Returns

string —

getLocalPort()

getLocalPort() : int

Get local port.

Returns

int —

getLocalAddress()

getLocalAddress() : string

Get local address.

Returns

string —

isIpV4()

isIpV4() : mixed

Is ipv4.

Returns

mixed —

isIpV6()

isIpV6() : mixed

Is ipv6.

Returns

mixed —

close()

close(mixed  $data = null, bool  $raw = false) : bool

Close connection.

Parameters

mixed $data
bool $raw

Returns

bool —

isIPv4()

isIPv4() : bool

Is ipv4.

Returns

bool —

isIPv6()

isIPv6() : bool

Is ipv6.

Returns

bool —

baseRead()

baseRead(resource  $socket) : bool

For udp package.

Parameters

resource $socket

Returns

bool —

connect()

connect() : void

Connect.