Transferring HashMap between client and server using Sockets (JAVA)

Posted by sar on Stack Overflow See other posts from Stack Overflow or by sar
Published on 2010-03-02T22:56:35Z Indexed on 2010/05/04 9:08 UTC
Read the original article Hit count: 147

I am working on a JAVA project in which there are multiple terminals. These terminals act as client and servers. For example if there are 3 terminals A,B and C.Then at any given point in time one of them say A, will be a client making broadcast request. The other two terminals, B and C, will reply. I am using sockets to make them communicate. Once the reply is received from all the other terminals A will check the pool of channels to see if any one of the channel is free. It takes up the free channel and making it availabilty false.

The channelpool is implemented using HashMAp:

HashMap channelpool = new HashMap();

channelpool = 1=true, 2=true, 3=false, 4=true, 5=true, 6=true, 7=true, 8=true, 9=true, 10=true

So initially all the channels are true, any terminal can take any channel. But once the channel is taken it is set to false for the period of use and then reset to true.

Now this Hashmap has to be shared among the distributed terminals. Also it should be kept up to date. I can not used a shared resource among the terminals to store the HashMap.Can someone tell me an easy way to transfer the HashMap between the terminals. I will appreciate if someone could point me to a website which discusses this.

© Stack Overflow or respective owner

Related posts about java

Related posts about client-server