tcpconnectionportsendlisten

Does TCP use another port for sending data?


I heard that for TCP connection, server will listen on 1 port, and use another port for sending data.

For example, web server listen on port 80. Whenever client connects to it, this server will use another port (say 9999) to send data (web content) to client. If multiple clients connect to it, does this server create multiple "another ports" to send data back ?

And does the client uses 2 ports (listening port and sending-data port) as the server does ?

Am I right? I heard many people said that and I can't find any good books or articles about this

Please explain


Solution

  • I heard that for TCP connection, server will listen on 1 port, and use another port for sending data.

    No. The same port is used for both listening and for accepted connections, and the same connection is normally used for both sending and receiving. TCP connections are bidirectional. FTP is an exception to this, as it uses two connections: one for commands and one for data.

    For example, web server listen on port 80. Whenever client connects to it, this server will use another port (say 9999) to send data (web content) to client.

    No.

    If multiple clients connect to it, does this server create multiple "another ports" to send data back ?

    No.

    And does the client uses 2 ports (listening port and sending-data port) as the server does ?

    No.

    Am I right?

    No.

    I heard many people said that

    They were all wrong.

    and I can't find any good books or articles about this

    There aren't any. Only a very bad book or article would say any such thing.