Results 1 to 16 of 16
  1. #1
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Server/Multi Clients HELP

    Hi everyBody

    actually, I have made a server/multi Clients where Clients send Double data but my problem is that the clients send this data to Server only wonce, and the server waits again the connection from client. (I have to run the clients manually each time)

    what i'm looking: the client should always send data to server. like an infinite loop.

    Can someone help me?

    the programs are shown below.

    thank you in advance
    Last edited by mbouras.f; 03-09-2014 at 11:36 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    Please edit your post and wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Exclamation Re: Server/Multi Clients HELP

    Hi everyBody

    actually, I have made a server/multi Clients where Clients send Double data but my problem is that the clients send this data to Server only wonce, and the server waits again the connection from client. (I have to run the clients manually each time)

    what i'm looking: the client should always send data to server. like an infinite loop.

    Can someone help me?

    the programs are shown below.

    thank you in advance
    Last edited by mbouras.f; 03-09-2014 at 11:33 PM.

  4. #4
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    Thanks Norm.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    client should always send data to server. like an infinite loop.
    What have you tried? The posted code does not have a loop in it.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    I tried this loop but it doesn't work!!!!

    Java Code:
    do{
    				Object o= new Object();
    				o= T_Calc();
    				oos.writeObject(o);
    				
    				
    			}while(!message.equals("bye"));

  7. #7
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    when I run the ClientSocket this error appears:

    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)

  8. #8
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.ObjectInputStream$PeekInputStream.read(Unk nown Source)
    at java.io.ObjectInputStream$BlockDataInputStream.rea d(Unknown Source)
    at java.io.ObjectInputStream$BlockDataInputStream.rea dFully(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknow n Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unkno wn Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at Test1serverMultiClients.ConnectionHandler.run(Serv er_Socket.java:83)
    at java.lang.Thread.run(Unknown Source)

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    Expand the loop so it includes most of the code in the run() method.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    yes I expand the while loop only in ClientSocket part. Serverhas recieved only one value and the an error occurs again:

    java.lang.NullPointerException
    at Test1serverMultiClients.ConnectionHandler.run(Serv er_Socket.java:85)
    at java.lang.Thread.run(Unknown Source)

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    java.lang.NullPointerException
    at Test1serverMultiClients.ConnectionHandler.run(Serv er_Socket.java:85)
    What variable has a null value at line 85? Why doesn't the variable have a valid value?
    If you don't understand my response, don't ignore it, ask a question.

  12. #12
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    the line 85 contains is the while condition!!!!!

    do{
    double k = (double)ois.readObject();
    System.out.println("Client> " + k);
    }while(!message.equals("bye")); -------> this is the line 85 in my code

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    What is in message?
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    I modified the code and the client send a value once then an error occurs in the second time

    java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
    at Test1serverMultiClients.ConnectionHandler.run(Serv er_Socket.java:88)
    at java.lang.Thread.run(Unknown Source)

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Server/Multi Clients HELP

    You need to post the new code that goes with the error message.
    The current code worked. You have made several changes to it besides the issue of sending lots of double values.
    The code is reading a Double and trying to cast it to a String.
    If you don't understand my response, don't ignore it, ask a question.

  16. #16
    mbouras.f is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: Server/Multi Clients HELP

    thanks Norm.
    I have found the solution.

Similar Threads

  1. server to serve multi clients
    By sana'a in forum Networking
    Replies: 10
    Last Post: 01-24-2012, 01:29 PM
  2. How to connect n clients to a server?
    By chyrl in forum Networking
    Replies: 21
    Last Post: 07-25-2010, 04:01 PM
  3. multi clients connect to udp server
    By bachma7 in forum Networking
    Replies: 5
    Last Post: 12-12-2008, 08:56 PM
  4. SSL Server with authentication of clients
    By zoltan in forum Networking
    Replies: 0
    Last Post: 10-14-2008, 11:27 PM
  5. blocked between server and clients
    By ibtehal in forum Networking
    Replies: 6
    Last Post: 07-17-2008, 12:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •