An open API service indexing awesome lists of open source software.

https://github.com/generaloss/network-forge

Network Library
https://github.com/generaloss/network-forge

Last synced: 5 months ago
JSON representation

Network Library

Awesome Lists containing this project

README

          

# [Network Forge](https://github.com/generaloss/network-forge)

[![Maven Central](https://img.shields.io/maven-central/v/io.github.generaloss/network-forge.svg)](https://mvnrepository.com/artifact/io.github.generaloss/network-forge)

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:

``` xml

io.github.generaloss
network-forge
26.1.1

```

Requirements:
* Java 11 or higher

---

## Quick Start

### TCP Server

``` java
TCPServer server = new TCPServer();
server.registerOnConnect(connection -> {
connection.send("Hello, client!");
});
server.registerOnReceive((senderConnection, data) -> {
String received = new String(data);
System.out.println(received); // Output: Hello, server!
});
server.registerOnDisconnect((connection, reason, e) -> {
server.close(); // close server
});
server.run(5555);
```

### TCP Client

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

---

## Documentation

See the [**Wiki**](https://github.com/generaloss/network-forge/wiki) for full guides and API documentation.

---

## Related Projects

* [Resource Flow](https://github.com/generaloss/resource-flow) - utility library used by Network Forge