Skip to main content

Posts

Featured

Socket Communication between Java programs running on different JVMs

There are multiple ways to implement inter process communication. In this article, I will describe how to write a simple Ping Pong server. The objective will be, the first process sends a "PING" to the second process. The second process reads it and replies with a "PONG". Lets iterate this 10 times. So, I will be using JDK 7 and will be using java.net.Socket class. Socket is built for Client - Server communication. That means, a Server should be running on a port in order to accept messages. The clients can then send requests on the port. So, the entire interaction revolves around both the java processes having both "Client" and "Server" threads running. That means, when Process A wants to send a "PING" message to the Process B, Process A will use its client thread to send me ssages. The server thread in Process 2 should already be started and accepting messages, and similarly, when Pr ocess 2 wants to send a "PONG" me

Latest posts

Build your own simple Video Streaming service

Some useful GIT commands

Move code from SVN to GIT

Create Jenkins Docker image with pre-configured data

Running Jenkins behind Nginx