🔨
Java Utility Package
🔨
Java Utility Package
  • Java Utility Package (Open Source)
  • Examples
    • 📖Logging
    • 🔧Utility Class
    • 🔑Password Vault
    • 🖥️HTTP / Socket Server
    • ⚒️HTTP Client
    • 🖥️Socket Client
    • 🗃️JDBC Database
    • ✉️SMTP Mailer
    • ⚔️Java Thread
    • 🗄️File Tools
    • ⌚Timer
    • 💡Tips / FAQ
  • Downloads
    • ⬇️Package ch.k43.util
    • ⬇️Sample Code
    • 📖JavaDoc API
    • 👨‍💻GitHub
Powered by GitBook
  1. Examples

Socket Client

Low-level access to any server socket

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

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());
   }
}

Last updated 3 months ago

🖥️
Page cover image