Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Messenger like system!!!!!!!!!!!

Avatar of player8
player8 asked on
Java
25 Comments1 Solution313 ViewsLast Modified:
Hi everyone,
            I am doing a client-server programming.
Consider the following:
Clients: c1,c2,c3,c4.
Server:s1.
    Suppose at first c1 gets connected to s1.Then suppose if i am having a combo box in the client side  that is used to display the ip-addressess of on-line clients nothing should be their as only one client c1 is available in the network.
Now suppose if another client c2 logs in and gets connected to s1,then the ipaddress of c2 should be immediately send to already on-line c1.So whenever a new client  gets connected to server ,that
clients ip-address should be send to all the previously on-line clients.
I have tried a code something similar to this but not meeting the actual purpose.
In the server part i have tried the following:(I am giving only the portion of code which i want to clarify):
query="Select * from clientdet where status='online'";
                  rs=stmt.executeQuery(query);
                while(rs.next()){
                      String strValue = rs.getString ( 3 ) ;
                  
                        pw.println ( strValue );
                                        }
                  pw.println ("done"  ) ;

client -side:

In client side in the click event of a command button i have the following code:
      while ( ( ipfromserver = br1.readLine () ) != null && ! ipfromserver.equalsIgnoreCase ( "done" ) ){
                                  //parr[i]=ipfromserver;
                                if(ipfromserver.equalsIgnoreCase("192.168.3.185"))
                                continue;                        
                                vlist.add(new String ( ipfromserver ) ) ;
                               // System.out.println("fff"+vlist(i));                        
                                //i++;
                         }
The problem with  my code is as follows:
Let c1 be the first to be connected to s1.Suppose c2 gets connected to s1,then
in c2's interface the combobox will contain the ip-address of already connected c1 but c1 will not contain the ip-adress of newly connected c2 or for that matter any clients after c1.Its just that i have not coded to meet the purpose.
Kindly help me with this.
Thank you.

ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank SFlag of India imagePrincipal Technologist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 25 Comments.
See Answers