Home > Net >  The Socket to send data
The Socket to send data

Time:12-14

Excuse me, if I send all use of a network cable, data continuously, I also constantly, if each other slowly, or don't accept, I such operations last: what is it?

CodePudding user response:

May be lost package, to check whether send buffer is full, if full stop to write data, or you will lost package,

CodePudding user response:

Don't need you to do anything,
TCP protocol itself has a complete mechanism to ensure data transceiver, this we don't explain yourself baidu "TCP moving window
"
In fact, a lot of people just starting this must solve a problem, that is, the hair not hair, nor accept

Because between you and sending cache, receiving cache, and the underlying protocol, the underlying communication guarantee,

So you said you closed, but it is not you, but the underlying charge, you just took from the buffer and buffer to tell the other party can send a physical package under the moving window
But you said not to hold, it's not you don't stop, you are in the buffer, the underlying this according to the agreement to determine whether need to send a physical package under the moving window, if the other party slowly, moving window is moving slowly, if they don't accept, the buffer is full or send timeout, you will get an exception

So you don't need to do, you need to do is just waiting for the exception, without exception, that's just the network is slow, slow, you can do

CodePudding user response:

reference 1st floor icoolno1 response:
may be lost package, to check whether send buffer is full, if full stop to write data, otherwise will be lost package,

How do you know that the buffer is full?

CodePudding user response:

That I received data server, I deal with, with the tcpclient send data to the server using send (byte []), for the first time alignment is good, the second alignment data don't go out, I see a return value, but don't get, add a behind. Socketflag. NONE, is sent, the third time alignment, I only accept data program is full of problems, I am a open inspired data, my data at the receiving end is stuck, I don't send data, the receiver data and come over, I also is very fast, and then try to use sendasync (), my program will be out of memory, you know what is the reason?
  •  Tags:  
  • C#
  • Related