Results 1 to 5 of 5
  1. #1
    nadia is offline Member
    Join Date
    Dec 2008
    Posts
    13
    Rep Power
    0

    Angry how to make server Wait for clients further requests after establishing connection

    HI


    i am making my own simulation for SMTP server...
    i want to know how can i make server wait for clients request..

    1. i made connectivity of client with server
    2. now i display the GUI for client
    client sends variuos messages to Server e.g "signup", "signin" to tell server wat to do...
    My server side has statement

    msg = (String )oin.readObject();

    then server checks the message and performs... BUT client sends messages only when some ActionListeners get activated....

  2. #2
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    SMTP is defined only for ASCII lines. You should use
    readline()

    and just loop

  3. #3
    nadia is offline Member
    Join Date
    Dec 2008
    Posts
    13
    Rep Power
    0

    Default

    hi,

    i did it this way..
    try{
    msg = "";
    while(msg.equals(""))
    msg =new BufferedReader(new InputStreamReader(soc.getInputStream())).readLine( );
    }catch(Exception e){e.printStackTrace();System.out.println("Here"); }


    tell me where am i wrong

  4. #4
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Have you run this code? It looks terrible.
    Get the BufferedReader once, outside the loop.
    Inside the loop, call readline()

  5. #5
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    I'm not sure what you are doing at the socket level, but don't just read the input stream. Wait on the socket, and then read the input stream. Sockets default to blocking mode, so they wait for input on their own.

    If you are using Java 1.6, then use ServerSocketChannel. Then you won't have to read the input stream. You'll get a ByteBuffer, loaded with the input, instead.

Similar Threads

  1. HTTP requests through proxy server
    By manolowar in forum Networking
    Replies: 3
    Last Post: 01-20-2009, 05:52 AM
  2. multi clients connect to udp server
    By bachma7 in forum Networking
    Replies: 5
    Last Post: 12-12-2008, 09:56 PM
  3. Replies: 5
    Last Post: 11-08-2008, 07:15 AM
  4. SSL Server with authentication of clients
    By zoltan in forum Networking
    Replies: 0
    Last Post: 10-15-2008, 12:27 AM
  5. blocked between server and clients
    By ibtehal in forum Networking
    Replies: 6
    Last Post: 07-17-2008, 01: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
  •