0

I have a Java Client/server application where I share a file (tsv file) with a single client, this client can view and modify it in his UI and send back the updated version to the server. I am doing this using TCP sockets.

Now I would like to make it available to multiple client. To achieve that I wanted to use the following "protocol" : - Every time a modification is made on a client, he sends to the server the modified record with some information about the modification (EDIT, ADD, DELETE). The server receives this and send the modification to all the connected clients. - Then I make the client "listening" to the server on the socket inputstream in a separate thread, waiting for update notices.

My problem is that the communication in sockets is not working with that design. I don't know where it comes from, when I debug my code a "receive" method is blocking. I think it might be because on the client socket side I am receiving messages in two different threads on the same inputStream, is it a problem to do that ? Otherwise should I open 2 sockets with every client, one to listen for updates and one for regular use ?

If you have any other suggestion on the protocol I should use, I will be glad to hear them :)

Kilian
  • 13
  • 1
  • 3

1 Answers1

0

I think, you can use Websockets to achieve this.

R Kaja Mohideen
  • 909
  • 1
  • 8
  • 24
  • Thanks for the advice, but I want to keep using java sockets and using a simple terminal interface for this application – Kilian Jan 15 '15 at 12:26
  • Then your socket should be bi-directional in nature. And, you have to use some RPC mechanism to easily detect the message type (request / response / notification ) – R Kaja Mohideen Jan 16 '15 at 06:45