Socket
Table of Contents
Namespaces
Interfaces
- ServerSocket
- ServerSocketFactory
- Socket
- A `ReadableStream` allows reading byte streams in chunks.
- SocketAddress
- SocketConnector
- SocketPool
- Allows pooling of connections for stateless protocols.
- UdpSocket
Classes
- BindContext
- Certificate
- CidrMatcher
- ClientTlsContext
- ConnectContext
- ConnectException
- Thrown if connecting fails.
- DnsSocketConnector
- InternetAddress
- PendingAcceptError
- Thrown in case a second read operation is attempted while another read operation is still pending.
- PendingReceiveError
- Thrown in case a second read operation is attempted while another receive operation is still pending.
- ResourceServerSocket
- ResourceServerSocketFactory
- ResourceSocket
- ResourceUdpSocket
- RetrySocketConnector
- ServerTlsContext
- SocketException
- Socks5SocketConnector
- StaticSocketConnector
- Connector that connects to a statically defined URI instead of the URI passed to the {@code connect()} call.
- TlsException
- Thrown if TLS can't be properly negotiated or is not supported on the given socket.
- TlsInfo
- Exposes a connection's negotiated TLS parameters.
- UnixAddress
- UnlimitedSocketPool
- SocketPool implementation that doesn't impose any limits on concurrent open connections.
Enums
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
Return values
ResourceServerSocketbindUdpSocket()
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
Return values
ResourceUdpSocketsocketConnector()
Set or access the global SocketConnector instance.
socketConnector([SocketConnector|null $connector = null ]) : SocketConnector
Parameters
- $connector : SocketConnector|null = null
Return values
SocketConnectorconnect()
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
Return values
SocketconnectTls()
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
Return values
SocketcreateSocketPair()
Returns a pair of connected stream socket resources.
createSocketPair([positive-int $chunkSize = ResourceSocket::DEFAULT_CHUNK_SIZE ]) : ResourceSocket}
Parameters
- $chunkSize : positive-int = ResourceSocket::DEFAULT_CHUNK_SIZE
Tags
Return values
ResourceSocket} —Pair of socket resources.
hasTlsAlpnSupport()
hasTlsAlpnSupport() : bool
Tags
Return values
boolhasTlsSecurityLevelSupport()
hasTlsSecurityLevelSupport() : bool