Documentation

functions.php

Table of Contents

Functions

listen()  : ResourceServerSocket
Listen for client connections on the specified server address.
bindUdpSocket()  : ResourceUdpSocket
Create a new Datagram (UDP server) on the specified server address.
socketConnector()  : SocketConnector
Set or access the global SocketConnector instance.
connect()  : Socket
Establish a socket connection to the specified URI.
connectTls()  : Socket
Establish a socket connection to the specified URI and enable TLS.
createSocketPair()  : ResourceSocket}
Returns a pair of connected stream socket resources.
hasTlsAlpnSupport()  : bool
hasTlsSecurityLevelSupport()  : bool

Functions

listen()

Listen for client connections on the specified server address.

listen(SocketAddress|string $address[, BindContext|null $bindContext = null ][, positive-int $chunkSize = ResourceSocket::DEFAULT_CHUNK_SIZE ]) : ResourceServerSocket

If you want to accept TLS connections, you have to use yield $socket->setupTls() after accepting new clients.

Parameters
$address : SocketAddress|string

URI in scheme://host:port format. TCP is assumed if no scheme is present.

$bindContext : BindContext|null = null

Context options for listening.

$chunkSize : positive-int = ResourceSocket::DEFAULT_CHUNK_SIZE

Chunk size for the accepted sockets.

Tags
throws
SocketException

If binding to the specified URI failed.

Return values
ResourceServerSocket

bindUdpSocket()

Create a new Datagram (UDP server) on the specified server address.

bindUdpSocket(InternetAddress|string $address[, BindContext|null $bindContext = null ][, positive-int $limit = ResourceUdpSocket::DEFAULT_LIMIT ]) : ResourceUdpSocket
Parameters
$address : InternetAddress|string

URI in scheme://host:port format. UDP is assumed if no scheme is present.

$bindContext : BindContext|null = null

Context options for listening.

$limit : positive-int = ResourceUdpSocket::DEFAULT_LIMIT

Maximum size for received messages.

Tags
throws
SocketException

If binding to the specified URI failed.

Return values
ResourceUdpSocket

connect()

Establish a socket connection to the specified URI.

connect(SocketAddress|string $uri[, ConnectContext|null $context = null ][, Cancellation|null $cancellation = null ]) : Socket
Parameters
$uri : SocketAddress|string

URI in scheme://host:port format. TCP is assumed if no scheme is present.

$context : ConnectContext|null = null

Socket connect context to use when connecting.

$cancellation : Cancellation|null = null
Tags
throws
ConnectException
throws
CancelledException
Return values
Socket

connectTls()

Establish a socket connection to the specified URI and enable TLS.

connectTls(SocketAddress|string $uri[, ConnectContext|null $context = null ][, Cancellation|null $cancellation = null ]) : Socket
Parameters
$uri : SocketAddress|string

URI in scheme://host:port format. TCP is assumed if no scheme is present.

$context : ConnectContext|null = null

Socket connect context to use when connecting.

$cancellation : Cancellation|null = null
Tags
throws
ConnectException
throws
TlsException
throws
CancelledException
Return values
Socket

hasTlsSecurityLevelSupport()

hasTlsSecurityLevelSupport() : bool
Return values
bool

        
On this page

Search results