Socket
class in package klyn.net

    public class Socket implements AutoClosable:

Socket
All Implemented Interfaces: AutoClosable

TCP client socket.

The socket uses blocking I/O.

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | isConnected `isConnected as Boolean:` | Returns true when the socket has a valid native handle.
public readonly property | reader `reader as SocketReader:` | Read-only property alias for `getReader()`.
public readonly property | remoteSocketAddress `remoteSocketAddress as SocketAddress:` | Returns the remote socket endpoint when known.
public readonly property | writer `writer as SocketWriter:` | Read-only property alias for `getWriter()`.

Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | Socket `Socket() throws IOException:` | Creates a socket and connects when endpoint parameters are provided.
public | Socket `Socket(host as String, port as Int) throws IOException:` | Creates a socket and connects when endpoint parameters are provided.
public | Socket `Socket(host as String, port as Int, timeoutMillis as Int) throws IOException:` | Performs a network operation.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public override | close `close() as Void throws IOException:` | Closes the socket.
public | connect `connect(host as String, port as Int) as Void throws IOException:` | Connects this socket.
public | connectWithTimeout `connectWithTimeout(host as String, port as Int, timeoutMillis as Int) as Void throws IOException:` | Performs a network operation.
public | getInputStream `getInputStream() as SocketInputStream:` | Returns the input stream wrapper.
public | getOutputStream `getOutputStream() as SocketOutputStream:` | Returns the output stream wrapper.
public | getReader `getReader() as SocketReader:` | Returns a text reader facade over this socket.
public | getWriter `getWriter() as SocketWriter:` | Returns a text writer facade over this socket.
public | readAllText `readAllText() as String throws IOException:` | Reads the whole socket stream as text.
public | readLine `readLine() as String throws IOException:` | Reads one line from the socket.
public | receive `receive() as String throws IOException:` | Receives text data from the peer.
public | receive `receive(maxBytes as Int) as String throws IOException:` | Receives text data from the peer.
public | receiveBytes `receiveBytes(maxBytes as Int = 4096) as Byte[] throws IOException:` | Receives raw bytes from the peer.
public | send `send(data as String) as Boolean throws IOException:` | Sends text data to the peer.
public | sendBytes `sendBytes(data as Byte[]) as Int throws IOException:` | Sends raw bytes to the peer.
public | setTimeoutMillis `setTimeoutMillis(timeoutMillis as Int) as Void throws IOException:` | Performs a network operation.
public | write `write(readonly value as String) as Void throws IOException:` | Writes raw text to the socket.
public | writeBytes `writeBytes(readonly value as Byte[]) as Void throws IOException:` | Writes raw bytes to the socket.
public | writeLine `writeLine(readonly value as String) as Void throws IOException:` | Writes one line to the socket.

Methods inherited from AutoClosable: close