Skip to content

generaloss/network-forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

A lightweight and flexible Java networking library for building custom networked applications.

It provides packet-oriented TCP connections, fine-grained socket option control, and optional encryption with JCE ciphers.


Installation

Add the dependency from Maven Central:

<dependency>
    <groupId>io.github.generaloss</groupId>
    <artifactId>network-forge</artifactId>
    <version>25.10.2</version>
</dependency>

Quick Start

TCP Server

TCPServer server = new TCPServer();
server.setOnConnect(connection -> {
    connection.send("Hello, client!");
});
server.setOnReceive((senderConnection, byteArray) -> {
    String received = new String(byteArray);
    System.out.println(received); // Output: Hello, server!
});
server.setOnDisconnect((connection, reason, e) -> {
    server.close(); // close server
});
server.run(5555);

TCP Client

TCPClient client = new TCPClient();
client.setOnReceive((connection, byteArray) -> {
    String received = new String(byteArray);
    System.out.println(received); // Output: Hello, client!
    client.close(); // disconnect client
});
client.connect("localhost", 5555);
client.send("Hello, server!");

Documentation

See the Wiki for full guides and API documentation.


Related Projects