Package io.ktor.network.sockets

Types

Link copied to clipboard
interface ABoundSocket

Represents a bound socket

Link copied to clipboard
interface Acceptable<out S : ASocket> : ASocket

Represents a socket source, for example server socket

Link copied to clipboard
interface AConnectedSocket : AWritable

Represent a connected socket

Link copied to clipboard
interface AReadable

Represent a readable socket

Link copied to clipboard
interface ASocket : Closeable, DisposableHandle

Base type for all async sockets

Link copied to clipboard
interface AWritable

Represents a writable socket

Link copied to clipboard

Represents a bound datagram socket

Link copied to clipboard
interface Configurable<out T : Configurable<T, Options>, Options : SocketOptions>

Represent a configurable socket

Link copied to clipboard

Represents a connected datagram socket.

Link copied to clipboard
class Connection(socket: Socket, input: ByteReadChannel, output: ByteWriteChannel)

Represents a connected socket with its input and output

Link copied to clipboard
class Datagram(packet: ByteReadPacket, address: NetworkAddress)

UDP datagram with packet content targeted to address

Link copied to clipboard
interface DatagramReadChannel

A channel for receiving datagrams

Link copied to clipboard
interface DatagramReadWriteChannel : DatagramReadChannel, DatagramWriteChannel

A channel for sending and receiving datagrams

Link copied to clipboard
interface DatagramWriteChannel

A channel for sending datagrams

Link copied to clipboard
interface ReadWriteSocket : ASocket, AReadable, AWritable

Represents both readable and writable socket

Link copied to clipboard
interface ServerSocket : ASocket, ABoundSocket, Acceptable<Socket>

Represents a server bound socket ready for accepting connections

Link copied to clipboard
interface Socket : ReadWriteSocket, ABoundSocket, AConnectedSocket

Represents a connected socket

Link copied to clipboard
class SocketBuilder : Configurable<SocketBuilder, SocketOptions>

Socket builder

Link copied to clipboard
sealed class SocketOptions

Socket options builder

Link copied to clipboard
expect class SocketTimeoutException : IOException
actual typealias SocketTimeoutException = SocketTimeoutException
actual class SocketTimeoutException : IOException
Link copied to clipboard
class TcpSocketBuilder(selector: SelectorManager, options: SocketOptions) : Configurable<TcpSocketBuilder, SocketOptions>

TCP socket builder

Link copied to clipboard
inline class TypeOfService(value: UByte)

An inline class to hold a IP ToS value

Link copied to clipboard

UDP socket builder

Functions

Link copied to clipboard
fun aSocket(selector: SelectorManager): SocketBuilder

Start building a socket

Link copied to clipboard
suspend fun ASocket.awaitClosed()

Await until socket close

Link copied to clipboard
suspend fun TcpSocketBuilder.connect(remoteAddress: SocketAddress, configure: SocketOptions.TCPClientSocketOptions.() -> Unit = {}): Socket
Link copied to clipboard
fun Socket.connection(): Connection

Opens socket input and output channels and returns connection object

Link copied to clipboard
fun AReadable.openReadChannel(): ByteReadChannel

Open a read channel, could be done only once

Link copied to clipboard
fun AWritable.openWriteChannel(autoFlush: Boolean = false): ByteWriteChannel

Open a write channel, could be opened only once

Link copied to clipboard
fun <T : Configurable<T, *>> T.tcpNoDelay(): T

Set TCP_NODELAY socket option to disable the Nagle algorithm.

Properties

Link copied to clipboard
val ASocket.isClosed: Boolean

Check if the socket is closed