dshcherbatiuk / java-nio

Examples what we can do with Java NIO Library and how we can manipulate with TCP Flow Control.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java-nio

Follow the link to find Presentation

Follow the link to find Javeloper Presentation

There are 3 examples using Java Nio library:

1. Simple Echo server implementation app/src/main/java/com/nio/EchoServer.java

  1. Build project using gradle clean && gradle build
  2. Run the server using java -cp . app/src/main/java/com/nio/EchoServer.java
  3. Connect to the server using nc -v 0.0.0.0 5555

2. Tcp server implementation of Reactor pattern app/src/main/java/com/nio/reactor/TcpServer.java

  1. Build project using gradle clean && gradle build
  2. Run the server using java -cp . app/src/main/java/com/nio/reactor/TcpServer.java
  3. Connect to the server using nc -v 0.0.0.0 5555

3. Tcp server implementation provided Data Flow Control app/src/main/java/com/nio/TcpDataFlowExample.java

  1. Build project using gradle clean && gradle build
  2. Run the server using java -cp . app/src/main/java/com/nio/TcpDataFlowExample.java
  3. Connect to the data channel nc -v 0.0.0.0 5555
  4. Connect to the control channel nc -v 0.0.0.0 4444

The idea of the project to show how we can manipulate with TCP Flow Control using Java Nio. There data and control channels. The data channel receive inbound data and convert it to UPPERCASE (just for fun). The control channel has 2 commands stop-read and start-read data to manipulate with data in the data channel. When we send stop-read command to the control channel the data channel will stop receive inbound data. In such case we can get TCP Window Size to 0. To start read data again we need to send start-read command and after that all data are contained to the queue will be received by the data channel.

To send huge amount of data you can generate it here https://json-generator.com

References

Basic

  1. ITT 2015 - Heinz Kabutz - The Multi-threading, Non Blocking IO
  2. Java NIO Tutorial
  3. Scalable IO in Java

Advanced

  1. Queueing in the Linux Network Stack
  2. Multi-queue improvements in Linux kernel Ethernet driver mvneta
  3. TCP/IP Illustrated, Volume 1: The Protocols, 2nd Edition
  4. Java NIO - Reactor
  5. SSL Introduction with Sample Transaction and Packet Exchange
  6. Java SSLEngine
  7. Performance and scalability analysis of Java IO and NIO based server models, their implementation and comparison

About

Examples what we can do with Java NIO Library and how we can manipulate with TCP Flow Control.


Languages

Language:Java 96.5%Language:Dockerfile 3.1%Language:Shell 0.4%