Some questions about sockets and accept ()

Suppose we created a socket with socket(), then we used bind()and listen(). Then we use accept()to wait for client requests after connecting the client, if we shut down the server (for example, ctrl + c process).

  • Is the client still connected to the port?
  • Is there any way to reconnect to a socket?
  • Is this a client side issue? Or recvfrom()wait until someone returns to the socket?
+4
source share
2 answers

I assume you are using TCP.

If we stop the server:

  • Is the client still connected to the port?

    . , , , . (, ), , , - , , . TCP Keep-Alive , , , .

  • - ?

    . .

  • ? recvfrom() , - ?

    recvfrom() . " " "" , . .

+3

?

reset Windows EOS * nix reset .

- ?

. , , . .

?

, . .

recvfrom() , - ?

, .

. recv(). - recvfrom() , , getpeername() .

+2

Source: https://habr.com/ru/post/1668838/


All Articles