Java NIO and TCP Connections

From NovaOrdis Knowledge Base
Revision as of 18:05, 25 July 2018 by Ovidiu (talk | contribs) (→‎Server)
Jump to navigation Jump to search

Internal

Overview

This article describes the programming model involved in establishing a simple TCP connection and interacting with it with non-blocking I/O, from Java. We use Java NIO APIs primitives introduced in Java 4.

Programming Model

Server

The server code uses a Selector to multiplex over two selectable channels: a ServerSocketChannel

Client

JavaNIOAndTCPConnections.png

Example

Playground Java NIO and TCP Connections