Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Multiple socket on same port

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multiple socket on same 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
    Junior Member
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Multiple socket on same port

    It's impossible. There would be no way to differentiate.
    Sam Barrow
    The Error DB

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Location
    USA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Multiple socket on same port

    Well I'm not entirely sure I understand your question, but do you mean if say a server listened for connections on one port and multiple clients could try to connect?

    In that case yes, each client is going to try to connect to the server on the same port, but once the connection is established the server actually "moves" that connection to a different port for each client. This is all transparent and doesn't require any special coding, I believe they're called virtual ports or something like that.

    But think of a web server, every client connects to it on port 80 but that doesn't mean that if, say 10 people are connected to it at the same time they are all being funneled through the same port 80. They just connect on port 80, once their connected they get their own port specifically for the communication between that particular client and the server.

    So long as you have a way to take care of all the clients simultaneously (multithreading usually) then multiple clients can Connect through the same port - but the data flow won't occur over just that one single port.

    Good luck!
    ... Ellipsis ...
    Java | C/C++ | x86 Assembly | Python
    HTML | PHP | CSS | Flash Actionscript

Similar Threads

  1. Socket C
    By ighor10 in forum Java Networking
    Replies: 0
    Last Post: June 22nd, 2010, 06:56 AM
  2. problem for writing to parallel port LPT1 on windows by RXTX library
    By sahar_m in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: April 20th, 2010, 04:31 AM
  3. theory about serial / parallel port & java
    By wolfgar in forum Java Theory & Questions
    Replies: 5
    Last Post: January 4th, 2010, 09:08 PM
  4. Serail Port Programming regarding phone line hook
    By maskey_dipesh in forum Java SE APIs
    Replies: 2
    Last Post: September 4th, 2009, 05:12 AM
  5. Replies: 2
    Last Post: October 7th, 2008, 11:03 PM