Socket behavior of send () and recv ()

The following is the setting:

Server client
 | |
accept connect
 | |
 v |
send msg1-> | 
 | |
 vv
recv <- send
 | |
 vv
send msg2-> recv
 | |
 vv
               close

Here is my question:
1. The client actually receives msg1 before closing it, why is this so?
2. send the msg2 message normally. Since the client closes after receiving the msg1 message, why is msg2 sent successfully?

PS I am using streaming socket for TCP.

+3
source share
2 answers
  • recv , . , , msg1. , , recv msg1 msg2, msg2 , recv.

  • send , recv, . , . , , .

+4

, , , recv() , send() .

+4

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


All Articles