> For the complete documentation index, see [llms.txt](https://java-util.k43.ch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://java-util.k43.ch/examples/socket-client.md).

# Socket Client

### KSocketClient Class Overview

* **TLS and Non-TLS Connection Support**\
  Enables secure and non-secure connections to server applications, providing flexibility for various use cases.
* **Client Authentication**\
  Supports client authentication using Java KeyStore (JKS) files for enhanced security during communication.
* **Versatile Read/Write Methods**\
  Provides efficient methods for reading and writing data in multiple formats, including byte\[], char\[], String, and line-based input.

### Example

```java
try (KSocketClient tlsSocket = new KSocketClient("example.com", 4443)) {
   KLog.abort(!tlsSocket.isConnected(), "Connect failed - " + tlsSocket.getLastError());

   while ((String hostLine = tlsSocket.readLine()) != null) {
      System.out.println(hostLine + K.getLineSeparator());
   }
}
```
