Provides the ability to work with TCP, UDP, and TLS.
- Example
import fs2.Stream import fs2.io.net.{Datagram, Network} def send[F[_]: Network](datagram: Datagram): F[Unit] = Network[F].openDatagramSocket().use { socket => socket.write(packet) }In this example, the
F[_]parameter tosendrequires theNetworkconstraint instead of requiring the much more powerfulAsyncconstraint. TheNetworkinstance has a set of global resources used for managing sockets. Alternatively, use thesocketGroupanddatagramSocketGroupoperations to manage the lifecycle of underlying resources. An instance ofNetworkis available for any effectFwhich has anAsync[F]instance.- Companion
- object
Value members
Abstract methods
Inherited methods
Opens a TCP connection to the specified server.
Opens a TCP connection to the specified server.
The connection is closed when the resource is released.
- Value Params
- options
socket options to apply to the underlying socket
- to
address of remote server
- Inherited from
- SocketGroup
Creates a UDP socket bound to the specified address.
Creates a UDP socket bound to the specified address.
- Value Params
- address
address to bind to; defaults to all interfaces
- options
socket options to apply to the underlying socket
- port
port to bind to; defaults to an ephemeral port
- protocolFamily
protocol family to use when opening the supporting
DatagramChannel
- Inherited from
- DatagramSocketGroup
Creates a TCP server bound to specified address/port and returns a stream of client sockets -- one per client that connects to the bound address/port.
Creates a TCP server bound to specified address/port and returns a stream of client sockets -- one per client that connects to the bound address/port.
When the stream terminates, all open connections will terminate as well. Because of this, make sure to handle errors in the client socket Streams.
- Value Params
- address
address to accept connections from; none for all interfaces
- options
socket options to apply to the underlying socket
- port
port to bind
- Inherited from
- SocketGroup
Like server but provides the SocketAddress of the bound server socket before providing accepted sockets.
Like server but provides the SocketAddress of the bound server socket before providing accepted sockets.
Make sure to handle errors in the client socket Streams.
- Inherited from
- SocketGroup