Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
In socket programming, why a client is not bind to an address?

In socket programming, I see that the server is bind to an address- comprising of IP and port number. Then the steps are listen, and accept ( blocking call). I am wondering why the client doesn't need to bind with its ip address and port number. In fact, it binds with the server socket address. Afterwards, the client calls the connect() call to establish a connection. Later, client and server both can speak to each other. How a server can speak to the client? The client has not bind with its IP address and port number. How is it possible for a server to reach client?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I am wondering why the client doesn't need to bind with its ip address and port number.

Because there is an internal bind() as part of connect(), if the socket isn't already bound, and because the server doesn't care what the client's port number is: it doesn't need to be fixed like the server's port number.

In fact, it binds with the server socket address.

No it doesn't: it connects to the server's address.

How a server can speak to the client?

Over the connection that has been established.

The client has not bind with its IP address and port number.

Yes it has, see above.

How is it possible for a server to reach client?

Same way the client reaches the server. By sending a packet with a target address and port.

over 4 years ago · Santiago Trujillo Relatório

0

Choosing the client port number is usually done by the kernel. This makes sense as only the kernel knows which ports are currently in use. However, you are free to specify the client port on your own, but I think it is hard for client program to make sure the port is free. It could just "try an error"

Choosing the clients IP address is also usually done by the kernel, by consulting the IP routing tables. You can show and modify them using the route command.


You've asked how the server can know the clients IP address. You need to understand TCP/IP in order to answer your question. Read the wiki article. It should be a good starting point.

over 4 years ago · Santiago Trujillo Relatório

0

It's because client always have to connect to the server. Client can be called as slave and server is always the master. But server can speak to the client only if there is the particular code given such Buffered Inputstream. other wise it can't send any input to client even if there is a connection. Port number is basically the address of the program stored in the server computer. so when the program in client side has to contact server side it needs port number so server side doesn't needs client's port number as the client program itself wants to access server program.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda