Packages

sealed trait Network[F[_]] extends SocketGroup[F] with DatagramSocketGroup[F]

Provides the ability to work with TCP, UDP, and TLS.

Source
Network.scala
Example:
  1. 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 to send requires the Network constraint instead of requiring the much more powerful Async constraint. The Network instance has a set of global resources used for managing sockets. Alternatively, use the socketGroup and datagramSocketGroup operations to manage the lifecycle of underlying resources. An instance of Network is available for any effect F which has an Async[F] instance.

Linear Supertypes
DatagramSocketGroup[F], SocketGroup[F], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Network
  2. DatagramSocketGroup
  3. SocketGroup
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def client(to: SocketAddress[Host], options: List[SocketOption] = List.empty): Resource[F, Socket[F]]

    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.

    to

    address of remote server

    options

    socket options to apply to the underlying socket

    Definition Classes
    SocketGroup
  2. abstract def datagramSocketGroup(threadFactory: ThreadFactory = ...): Resource[F, DatagramSocketGroup[F]]

    Provides an isolated DatagramSocketGroup[F] with the specified thread configuration.

    Provides an isolated DatagramSocketGroup[F] with the specified thread configuration. The resulting socket group is shutdown during resource finalization, resulting in closure of any sockets that were created.

    Note: Network is a DatagramSocketGroup so only use this operation if you need explicit control over the lifecycle of the socket group.

    threadFactory

    factory used to create selector thread

  3. abstract def openDatagramSocket(address: Option[Host] = None, port: Option[Port] = None, options: List[SocketOption] = Nil, protocolFamily: Option[ProtocolFamily] = None): Resource[F, DatagramSocket[F]]

    Creates a UDP socket bound to the specified address.

    Creates a UDP socket bound to the specified address.

    address

    address to bind to; defaults to all interfaces

    port

    port to bind to; defaults to an ephemeral port

    options

    socket options to apply to the underlying socket

    protocolFamily

    protocol family to use when opening the supporting DatagramChannel

    Definition Classes
    DatagramSocketGroup
  4. abstract def server(address: Option[Host] = None, port: Option[Port] = None, options: List[SocketOption] = List.empty): Stream[F, Socket[F]]

    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.

    address

    address to accept connections from; none for all interfaces

    port

    port to bind

    options

    socket options to apply to the underlying socket

    Definition Classes
    SocketGroup
  5. abstract def serverResource(address: Option[Host] = None, port: Option[Port] = None, options: List[SocketOption] = List.empty): Resource[F, (SocketAddress[IpAddress], Stream[F, Socket[F]])]

    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.

    Definition Classes
    SocketGroup
  6. abstract def socketGroup(threadCount: Int = 1, threadFactory: ThreadFactory = ...): Resource[F, SocketGroup[F]]

    Provides an isolated SocketGroup[F] with the specified thread pool configuration.

    Provides an isolated SocketGroup[F] with the specified thread pool configuration. The resulting socket group is shutdown during resource finalization, resulting in closure of any sockets that were created.

    Note: Network is a SocketGroup so only use this operation if you need explicit control over the lifecycle of the socket group.

    threadCount

    number of threads to allocate in the fixed thread pool backing the NIO channel group

    threadFactory

    factory used to create fixed threads

  7. abstract def tlsContext: Builder[F]

    Returns a builder for TLSContext[F] values.

    Returns a builder for TLSContext[F] values.

    For example, Network[IO].tlsContext.system returns a F[TLSContext[F]].

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from DatagramSocketGroup[F]

Inherited from SocketGroup[F]

Inherited from AnyRef

Inherited from Any

Ungrouped