Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shouchenicu/unet
Unet is a lightweight and high performance UDP net framework developed using pure Java, it based on event model drive and used synchronous non-blocking IO.
https://github.com/shouchenicu/unet
client lightweight net nio non-blocking-io server udp
Last synced: 12 days ago
JSON representation
Unet is a lightweight and high performance UDP net framework developed using pure Java, it based on event model drive and used synchronous non-blocking IO.
- Host: GitHub
- URL: https://github.com/shouchenicu/unet
- Owner: ShouChenICU
- Created: 2023-06-17T06:30:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-21T15:54:12.000Z (about 1 year ago)
- Last Synced: 2024-10-10T16:41:43.658Z (about 1 month ago)
- Topics: client, lightweight, net, nio, non-blocking-io, server, udp
- Language: Java
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unet
Unet is a lightweight and high performance UDP net framework developed using pure Java,
it based on event model drive and used synchronous non-blocking IO.## Usage
```java
Unet unet = Unet.spawn(new UnetConfig().bindPort(1234));
unet.pipeline().addInboundHandler(buffer -> {
// Do something...
// Pass to the next processor
UnetContext.doRead(buffer);
}).addInboundHandler(buffer -> {
// Do something...
}).addOutboundHandler(buffer -> {
// Outbound handler chain
// Do something
UnetContext.doSend(buffer);
});// Async send messages
unet.fireSend(
ByteBuffer.wrap("hello".getBytes(StandardCharsets.UTF_8)),
new InetSocketAddress("target address", 1234)
);// Sync send messages
unet.fireSend(
ByteBuffer.wrap("hello".getBytes(StandardCharsets.UTF_8)),
new InetSocketAddress("target address", 1234)
).sync();
// sync call is synchronized, is equivalent to this
unet.pipeline().doSend(
ByteBuffer.wrap("hello".getBytes(StandardCharsets.UTF_8)),
new InetSocketAddress("target address", 1234)
);// Broadcast
unet.fireBroadcast(
ByteBuffer.wrap("hello".getBytes(StandardCharsets.UTF_8)),
1234
);
```## Build
**Requirement**
- JDK11+
- maven3**Command**
```shell
mvn clean package
```Now you can see it in the target folder.