Search code examples
tcpports

What is the minimum number of socket port(s) required for a TCP server?


Doing a some practice questions for exam tomorrow can't figure out this one

What is the minimum number of socket port(s) required for a TCP server to connect a TCP client for communication?

Surely its just two right? one for the server one for the client, but this seems to obvious. My mates thinks TCP uses two ports at the server end for for data in and one for data out.

thanks in advance


Solution

  • Typically one port/socket will be open on the server to listen for incoming connections. Once connected, the connection will have its own (different) socket allocated on the server to continue the conversation. So strictly speaking that's one port and two sockets on the server -- and one on the client if you wish to count that.

    EDIT: Yes I believe comments below are right -- editing answer above to distinguish between sockets and ports.