Client and Server sockets on same machine
I need to make 3 processes residing on different machines to communicate with each other. Each machine can talk to one other so each machine should have a ServerSocket to send outgoing messages and an client Socket to receive messages from others. When I try to run ServerSocket it goes in infinite loop as it is waiting for requests to be accepted, hence other parts of my program do not work. Can anyone help me as to how to implement this.
Here is my code
Whether I put serverSock.accept() in while loop or outside it doesnt reaches any of System.out.println() statements.
public class Networking
public void makeSockets()
serverSock = new ServerSocket(Port);
Socket sock = serverSock.accept();
PrintWriter serverWriter = new PrintWriter(sock.getOutputStream());
System.out.println("Is code working here");
// Everytime a new request comes it spawns a new worker thread
Worker newWorker = new Worker(sock);
System.out.println("Exception on new ServerSocket: " + ex);
clientStreamReader = new InputStreamReader(clientSock.getInputStream());
clientReader = new BufferedReader(clientStreamReader);
clientWriter = new PrintWriter(clientSock.getOutputStream());