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

StackOverflow https://stackoverflow.com/questions/2907168

  •  04-10-2019
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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.

Outras dicas

some protocols (like ftp) uses more than one port (one for control and one for data), but TCP in general can use one port at each sides.

The answer is two: one port on the server to both listen for new connections and service established ones and one port on the client.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top