Hello,
I'm making an application that supports sending text/files. It will use a server and 2+ clients. The clients won't communicate directly with each other, their messages will be forwarded by the server.
My problem is this: in C++, after starting a client, I'd have 1 thread stuck on RECEIVE (recv), for handling messages any time they'd come.
How do I do this in Java? thanks.
Socket socket = new Socket(host.getHostName(), 7777);
//
// Send a message to the client application
//
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject("Hello There");
//
// Read and display the response message sent by server application
//
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
String message = (String) ois.readObject();
System.out.println("Client: Message: " + message);