Socket Programming

Discussion in 'Java' started by Kathryn Bean, Sep 11, 2004.

  1. Kathryn Bean

    Kathryn Bean Guest

    In client/server application with Datagram, a client side sends a message
    to a server and puts itself to sleep. Can the client receive a replay from
    the server while sleeping or will the message be lost?

    How about Stream Socket?

    Thank you in advance.
    Kathryn
     
    Kathryn Bean, Sep 11, 2004
    #1
    1. Advertising

  2. On Sat, 11 Sep 2004 04:06:48 GMT, Kathryn Bean wrote:
    > In client/server application with Datagram, a client side sends a
    > message to a server and puts itself to sleep. Can the client receive
    > a replay from the server while sleeping or will the message be lost?
    >
    > How about Stream Socket?


    Replies can arrive at any time, but the application won't receive them
    until it actively reads from the connection (i.e. when it isn't
    sleeping). In any case, incoming data is buffered by the OS up to a
    point. This is true for both datagram (UDP) and stream (TCP)
    protocols.

    For UDP, if the application fails to keep up with the incoming data,
    the receive buffer will eventually fill and the OS will start dropping
    datagrams it doesn't have room for. Obviously sleeping will increase
    the risk of that happening.

    TCP provides flow control. If the receiver fails to keep up and the
    receive buffer fills, the sender will be prevented from sending more
    data until the receiver drains some of the backlog by reading from the
    stream.

    Why does the client put itself to sleep after sending a request to the
    server? If it has no other work to do it could just as well read from
    the connection, which is essentially the same as sleeping only until a
    response arrives.

    Do you have a Java question?

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Sep 13, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,916
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    991
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    565
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    683
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    729
Loading...

Share This Page