Need idea about client server connectivity (using ServerSocket and Socket)

Discussion in 'Java' started by JPractitioner, Feb 16, 2006.

  1. Hi guys,

    I have a class that listens to one port using ServerSocket. After
    successfully receiving a packet, can i reply back to the client, in a
    way that the client do not have to listen for incoming packets.

    Thx in advance.
     
    JPractitioner, Feb 16, 2006
    #1
    1. Advertising

  2. Re: Need idea about client server connectivity (using ServerSocketand Socket)

    JPractitioner wrote:
    > Hi guys,
    >
    > I have a class that listens to one port using ServerSocket. After
    > successfully receiving a packet, can i reply back to the client, in a
    > way that the client do not have to listen for incoming packets.


    If I understand your question correct, you are asking if the client can
    get a reply without having to listen on a port of its own for the reply?
    If that is the case then yes, in the jdk api page for the ServerSocket
    class it states that it is a TCP socket, which means that the client
    only has to do a read of the socket to get a reply.

    Or are you perhaps asking of you can come back to the socket at a later
    time to read the reply?

    /tom
     
    tom fredriksen, Feb 16, 2006
    #2
    1. Advertising

  3. JPractitioner

    Chris Uppal Guest

    JPractitioner wrote:

    > I have a class that listens to one port using ServerSocket. After
    > successfully receiving a packet, can i reply back to the client, in a
    > way that the client do not have to listen for incoming packets.


    Do you mean: without the client having to create, and listen on, a ServerSocket
    of its own ? If so then the answer is that when a ServerSocket recieves a
    connection, that creates a two-way stream between the client and the server.
    The server can send data back to the client on the newly created Socket. The
    client can read that data from the Socket connection that it opened to the
    server.

    If you mean something else, then I'm afraid you'll have to clarify what you
    mean.

    -- chris
     
    Chris Uppal, Feb 16, 2006
    #3
  4. Thanks a lot guys. Both answer are brilliant! I ve been enlightened.
    Thanks again.

    by the way, i was thinking to make a listener for the client as well.
    but i'm glad that i asked here.
     
    JPractitioner, Feb 16, 2006
    #4
    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. Avizz
    Replies:
    3
    Views:
    13,900
    Andy Fish
    Sep 29, 2003
  2. Jason Teagle
    Replies:
    12
    Views:
    3,276
    Jason Teagle
    Oct 5, 2003
  3. Sudheer
    Replies:
    2
    Views:
    1,333
    Roedy Green
    Apr 1, 2004
  4. Replies:
    7
    Views:
    1,544
    Steve W. Jackson
    Oct 11, 2005
  5. oziris
    Replies:
    5
    Views:
    2,739
Loading...

Share This Page