https://github.com/yevheniyj/nio-samples
Samples of Java NIO library usage
https://github.com/yevheniyj/nio-samples
java netty nio nio2
Last synced: 3 months ago
JSON representation
Samples of Java NIO library usage
- Host: GitHub
- URL: https://github.com/yevheniyj/nio-samples
- Owner: yevheniyJ
- Created: 2018-03-18T16:48:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-19T13:07:33.000Z (over 7 years ago)
- Last Synced: 2025-10-25T10:32:27.134Z (3 months ago)
- Topics: java, netty, nio, nio2
- Language: Java
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Samples with Java NIO library
[NioEchoServer](https://github.com/evgeniyJ/nio-samples/blob/master/src/main/java/org/evgeniy/ua/server/NioEchoServer.java) - simple TCP/IP server, which consumes data from client and writes into socket corresponding messages.
[NettyEchoServer](https://github.com/evgeniyJ/nio-samples/blob/master/src/main/java/org/evgeniy/ua/server/NettyEchoServer.java) - same echo server but using Netty framework.
[Nio2EchoServer](https://github.com/evgeniyJ/nio-samples/blob/master/src/main/java/org/evgeniy/ua/server/Nio2EchoServer.java) - same echo server but using NIO2 async channel.
[LoadTestingClient](https://github.com/evgeniyJ/nio-samples/blob/master/src/main/java/org/evgeniy/ua/client/LoadTestingClient.java) - class, which creates 10000 client connections, you can test load on your nio server.
[DirectoryWatchService](https://github.com/evgeniyJ/nio-samples/blob/master/src/main/java/org/evgeniy/ua/file/DirectoryWatchService.java) - simple usage of Watch Service API. Class which monitors changes in predefined directory.
You can play with generated jar file. Follow next steps :
- Run maven command : "mvn clean install" to build executable jar file;
- Execute : "java -jar target/nio-samples.jar args", where args could be next keywords :
- "server nio 8888" for NioEchoServer on port 8888;
- "server netty 7777" for NettyEchoServer on port 7777;
- "server nio2 3456" for Nio2EchoServer on port 3456;
- "client 7777" for LoadTestingClient and server runs on local machine on port 7777;
- "directory-watch D:\\watch" for DirectoryWatchService, where "D:\\watch" is directory to monitor.