ResourceUdpSocket
in package
implements
UdpSocket, ResourceStream
uses
ForbidCloning, ForbidSerialization
FinalYes
Table of Contents
Interfaces
Constants
- DEFAULT_LIMIT = 65507
Properties
- $address : InternetAddress
- $callbackId : string
- $cancel : callable(CancelledException): void
- $defaultLimit : int
- $limit : int
- $onClose : DeferredFuture
- $reader : Suspension|null
- $socket : resource|null
Methods
- __construct() : mixed
- __destruct() : mixed
- Automatically cancels the loop watcher.
- __serialize() : never
- __unserialize() : never
- close() : void
- Closes the datagram socket and stops receiving data. A pending {@code receive()} will return {@code null}.
- getAddress() : InternetAddress
- getResource() : resource|null
- Raw stream socket resource.
- isClosed() : bool
- Returns whether this resource has been closed.
- onClose() : void
- Registers a callback that is invoked when this resource is closed.
- receive() : null|InternetAddress, string}
- reference() : void
- References the event loop callback used for being notified about available packets.
- send() : void
- setLimit() : void
- unreference() : void
- Unreferences the event loop callback used for being notified about available packets.
- __clone() : mixed
- free() : void
Constants
DEFAULT_LIMIT
public
mixed
DEFAULT_LIMIT
= 65507
Properties
$address read-only
private
InternetAddress
$address
$callbackId read-only
private
string
$callbackId
$cancel read-only
private
callable(CancelledException): void
$cancel
$defaultLimit
private
int
$defaultLimit
$limit
private
int
$limit
$onClose read-only
private
DeferredFuture
$onClose
$reader
private
Suspension|null
$reader
= null
$socket
private
resource|null
$socket
UDP socket resource.
Methods
__construct()
public
__construct(resource $socket[, positive-int $limit = self::DEFAULT_LIMIT ]) : mixed
Parameters
- $socket : resource
-
A bound udp socket resource.
- $limit : positive-int = self::DEFAULT_LIMIT
-
Maximum size for received messages.
Tags
__destruct()
Automatically cancels the loop watcher.
public
__destruct() : mixed
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neverclose()
Closes the datagram socket and stops receiving data. A pending {@code receive()} will return {@code null}.
public
close() : void
getAddress()
public
getAddress() : InternetAddress
Return values
InternetAddressgetResource()
Raw stream socket resource.
public
getResource() : resource|null
Return values
resource|nullisClosed()
Returns whether this resource has been closed.
public
isClosed() : bool
Return values
bool —true if closed, otherwise false.
onClose()
Registers a callback that is invoked when this resource is closed.
public
onClose(Closure $onClose) : void
Parameters
- $onClose : Closure
receive()
public
receive([Cancellation|null $cancellation = null ][, positive-int|null $limit = null ]) : null|InternetAddress, string}
Parameters
- $cancellation : Cancellation|null = null
- $limit : positive-int|null = null
-
If null, the default chunk size is used.
Return values
null|InternetAddress, string}reference()
References the event loop callback used for being notified about available packets.
public
reference() : void
Tags
send()
public
send(InternetAddress $address, string $data) : void
Parameters
- $address : InternetAddress
- $data : string
setLimit()
public
setLimit(positive-int $limit) : void
Parameters
- $limit : positive-int
-
The new default maximum packet size to receive.
unreference()
Unreferences the event loop callback used for being notified about available packets.
public
unreference() : void
Tags
__clone()
protected
final __clone() : mixed
free()
private
free() : void