SokDoc

sok / Sok.Socket.TCP

Package Sok.Socket.TCP

Contains the heart of Sok. All the client and server socket classes are here

Types

TCPClientSocket expect class TCPClientSocket
Class representing a client socket. You can use it to perform any I/O operation. Keep in mind that this class keep an internal queue for write operations thus storing data until written so you should have some kind of backpressure mechanism to prevent the accumulation of too many data.
TCPServerSocket expect class TCPServerSocket
Class representing a listening socket. You can use it to perform accept() operation only.

Functions

createTCPClientSocket suspend expect fun createTCPClientSocket(address: String, port: Int): TCPClientSocket
Create a client socket with the given address and port. This function will throw a ConnectionRefusedException if the socket failed to connect.
createTCPServerSocket suspend expect fun createTCPServerSocket(address: String, port: Int): TCPServerSocket
Start a listening socket on the given address (or alias) and port