sealed trait Network[F[_]] extends AnyRef
Provides the ability to work with TCP, UDP, and TLS.
- Source
- Network.scala
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 tosendrequires theNetworkconstraint instead of requiring the much more powerfulAsync. An instance ofNetworkis available for any effectFwhich has anAsync[F]instance.
- Alphabetic
- By Inheritance
- Network
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
tcpSocketGroup: Resource[F, SocketGroup[F]]
Returns a TCP
SocketGroupas a resource.Returns a TCP
SocketGroupas a resource.The
SocketGroupsupports both server and client sockets. When the resource is used, a fixed thread pool is created and used to initialize ajava.nio.channels.AsynchronousChannelGroup. All network reads/writes occur on this fixed thread pool. The pool size is set to the number of processors returned byRuntime.getRuntime.availableProcessors. To customize this, usetcpSocketGroupWithConfig.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.
-
abstract
def
tcpSocketGroupWithConfig(nonBlockingThreadCount: Int = 0, nonBlockingThreadFactory: ThreadFactory = ...): Resource[F, SocketGroup[F]]
Like
tcpSocketGroupbut allows configuration of the fixed size thread pool used for NIO. -
abstract
def
tlsContext: Builder[F]
Returns a builder for
TLSContext[F]values.Returns a builder for
TLSContext[F]values.For example,
Network[IO].tlsContext.systemreturns aF[TLSContext[F]]. -
abstract
def
udpSocketGroup: Resource[F, SocketGroup[F]]
Returns a UDP
SocketGroupas a resource.Returns a UDP
SocketGroupas a resource.The
SocketGroupsupports 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.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.