Interface for open network socket connections.
Provides methods for standard operations available on sockets. All socket connection types in Icicle implement this socket interface, including both TCP and UDP socket types. A standard, full featured implementation is provided as
This interface extends
DuplexStream, so it inherits all the readable and writable stream methods as well as adding those specified below.
Socket::enableCrypto(int $method, float $timeout = 0): \Generator
Enables encryption on the socket. For Socket objects created from
Icicle\Socket\Server\Server::accept(), a PEM file must have been provided when creating the server socket (see
Icicle\Socket\Server\ServerFactory). Use the
STREAM_CRYPTO_METHOD_*_SERVER constants when enabling crypto on remote clients (e.g., created by
Icicle\Socket\Server\Server::accept()) and the
STREAM_CRYPTO_METHOD_*_CLIENT constants when enabling crypto on a local client connection (e.g., created by
Coroutine: Calls to this function must be preceded with
yield within another coroutine or wrapped with
new Coroutine() to create an awaitable.
- One of (or combination of) the server crypto flags, e.g.
STREAM_CRYPTO_METHOD_ANY_SERVERfor incoming (remote) clients,
STREAM_CRYPTO_METHOD_ANY_CLIENTfor outgoing (local) clients.
float $timeout = 0
- Seconds to wait between reads/writes to enable crypto before failing. Use
0for no timeout.
- If enabling crypto fails.
- If the socket is unreadable.
- If the socket is unwritable.
- Returns the local IP address as a string.
- Returns the local port.
- Returns the remote IP address as a string.
Returns the remote port.Next: Icicle\Stream