Package io.ktor.network.sockets

Types

ABoundSocket

interface ABoundSocket

Represents a bound socket

AConnectedSocket

interface AConnectedSocket : AWritable

Represent a connected socket

AReadable

interface AReadable

Represent a readable socket

ASocket

interface ASocket : Closeable, DisposableHandle

Base type for all async sockets

AWritable

interface AWritable

Represents a writable socket

Acceptable

interface Acceptable<out S : ASocket> : ASocket

Represents a socket source, for example server socket

BoundDatagramSocket

interface BoundDatagramSocket : 
    ASocket,
    ABoundSocket,
    AReadable,
    DatagramReadWriteChannel

Represents a bound datagram socket

Configurable

interface Configurable<out T : Configurable<T, O>, O : SocketOptions>

Represent a configurable socket

ConnectedDatagramSocket

interface ConnectedDatagramSocket : 
    ASocket,
    ABoundSocket,
    AConnectedSocket,
    ReadWriteSocket,
    DatagramReadWriteChannel

Represents a connected datagram socket.

Datagram

class Datagram

UDP datagram with packet content targeted to address

DatagramReadChannel

interface DatagramReadChannel

A channel for receiving datagrams

DatagramReadWriteChannel

interface DatagramReadWriteChannel : 
    DatagramReadChannel,
    DatagramWriteChannel

A channel for sending and receiving datagrams

DatagramWriteChannel

interface DatagramWriteChannel

A channel for sending datagrams

ReadWriteSocket

interface ReadWriteSocket : ASocket, AReadable, AWritable

Represents both readable and writable socket

ServerSocket

interface ServerSocket : 
    ASocket,
    ABoundSocket,
    Acceptable<Socket>

Represents a server bound socket ready for accepting connections

Socket

interface Socket : 
    ReadWriteSocket,
    ABoundSocket,
    AConnectedSocket

Represents a connected socket

SocketBuilder

class SocketBuilder : 
    Configurable<SocketBuilder, SocketOptions>

Socket builder

SocketOptions

sealed class SocketOptions

Socket options builder

TcpSocketBuilder

class TcpSocketBuilder : 
    Configurable<TcpSocketBuilder, SocketOptions>

TCP socket builder

TypeOfService

class TypeOfService

An inline class to hold a IP ToS value

UDPSocketBuilder

class UDPSocketBuilder : 
    Configurable<UDPSocketBuilder, UDPSocketOptions>

UDP socket builder

Properties

isClosed

val ASocket.isClosed: Boolean

Check if the socket is closed

Functions

aSocket

fun aSocket(selector: SelectorManager): SocketBuilder

Start building a socket

awaitClosed

suspend fun ASocket.awaitClosed(): Unit

Await until socket close

openReadChannel

fun AReadable.openReadChannel(): ByteReadChannel

Open a read channel, could be done only once

openWriteChannel

fun AWritable.openWriteChannel(
    autoFlush: Boolean = false
): ByteWriteChannel

Open a write channel, could be opened only once

tcpNoDelay

fun <T : Configurable<T, *>> T.tcpNoDelay(): T

Set TCP_NODELAY socket option to disable the Nagle algorithm.