NonStop Server for Java 7.0 Programmer's Reference

Figure 3 Client server application with TCP/IP and JI as communication channels
Application
Client Application
TCP
java.net.Socket/
java.nio.socketChannel
Application
Client Application
JI
java.net.Socket/
java.nio.socketChannel
TCP
Server Application
Application
java.net.Socket/
java.nio.socketChannel
JI
Server Application
Application
java.net.Socket/
java.nio.socketChannel
Pathsend / FS API
Without JI library With JI library
Sample code snippet in Table 10 (page 72) illustrates a simple client application that connects to
a server, sends data and in turn receives response. On the server side, the server code listens for
a connection and when the connection is established, it waits for the data and then responds back.
The sample code snippet and the subsequent sections help you to understand the functionality
illustrated in Figure 1 (page 17).
Table 10 Sample code snippet
Sample server codeSample client code
......
......
......
......
ServerSocket ssock = new (2) Socket sock = new
ServerSocket(8070);Socket(nonstop.server.com,8070);
............
(1) Socket sock = ssock.accept();OutputStream os = sock.getOutputStream();
......InputStream is = sock.getInputStream();
InputStream is = sock.getInputStream();......
(4) is.read();(3) os.write();
............
OutputStream os = sock.getOutputStream();(6) is.read();
(5) os.write();
......
......
sock.close();
......
The following table describes the behavior of the relevant calls when JI is enabled. For more
information on enabling JI, see “Enabling JI” (page 75). The server is configured to run as a TS/MP
72 Java infrastructure