Network

sealed trait Network[F <: ([_$1] =>> Any)]
Provides the ability to work with TCP, UDP, and TLS.
Example
{{{
import fs2.Stream
import fs2.io.{Network, udp}
def send[F[_] : Network](packet: udp.Packet): F[Unit] =
Network[F] .udpSocketGroup.open().use { socket =>
socket.write(packet)
}
}}}
In this example, the F[_] parameter to send requires the Network constraint instead
of requiring the much more powerful Async.
An instance of Network is available for any effect F which has an Async[F] instance.
Companion
object
class Object
trait Matchable
class Any

Value members

Methods

def tcpSocketGroup: Resource[F, SocketGroup[F]]
Returns a TCP SocketGroup as a resource.
The SocketGroup supports both server and client sockets. When the resource is used,
a fixed thread pool is created and used to initialize a java.nio.channels.AsynchronousChannelGroup.
All network reads/writes occur on this fixed thread pool. The pool size is set to the number
of processors returned by Runtime.getRuntime.availableProcessors. To customize this,
use tcpSocketGroupWithConfig.
When the socket group is finalized, the fixed thread pool is terminated and any future reads/writes
on sockets created by the socket group will fail.
def tcpSocketGroupWithConfig(nonBlockingThreadCount: Int, nonBlockingThreadFactory: ThreadFactory): Resource[F, SocketGroup[F]]
Like tcpSocketGroup but allows configuration of the fixed size thread pool used for NIO.
def udpSocketGroup: Resource[F, SocketGroup[F]]
Returns a UDP SocketGroup as a resource.
The SocketGroup supports both receiving and sending UDP datagrams.
When the resource is acquired, a dedicated thread is started, which
performs all non-blocking network calls. When the resource is finalized,
the thread is terminated and any sockets opened from the socket group
are closed.
Returns a builder for TLSContext[F] values.
For example, Network[IO].tlsContext.system returns a F[TLSContext[F]].