Results 1 to 3 of 3
  1. #1
    Sajith is offline Member
    Join Date
    Aug 2010
    Rep Power

    Default Multiple Sockets on a single Port

    Hello all, can more than a single socket be attached to a single port.(I tried this out, and ServerSocket returned a socket on the same port for each new client ) If yes, how will the server differentiate the streams of data from different clients, coming to the same port.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    On vacation
    Rep Power


    I'd never worried about that. It seems to work.
    Every new client connecting to the ServerSocket gets a new Socket via the accept method for the server to work with. There can be > 1 client connected at the same time.
    how will the server differentiate the streams of data from different clients
    By using the streams given by the Socket returned by accept.

    Are you having problems?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    Yes, you can have multiple sockets in a single port. It could be done in several ports.

    One possible way is keep one port for listening. Then upon request of a client, open another port unique for that connection, and free the previous port.

    Anyway, as Norm says, what's your real problem. If you can specific then we can comment more clearly on it.

Similar Threads

  1. Multiple Java in a single BOX
    By luke_devon in forum New To Java
    Replies: 2
    Last Post: 07-05-2010, 01:59 PM
  2. Single Tomcat Multiple Developers
    By Quentinb in forum Eclipse
    Replies: 3
    Last Post: 06-14-2010, 01:40 PM
  3. Replies: 5
    Last Post: 11-09-2009, 07:12 PM
  4. multiple users with single connection
    By nishi.kishore in forum Java Servlet
    Replies: 3
    Last Post: 09-06-2009, 03:15 PM
  5. Replies: 6
    Last Post: 07-28-2008, 06:04 PM

Posting Permissions

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