Home > Back-end >  TClientSocket buffer
TClientSocket buffer

Time:09-21

Use Timer intervals of 50 ms client sends data to the server, the server to determine again after the packet length, but run after period of time the client sendbuf will return 1, WSAGetLastError () for 10035, the server receives the packet length also does not conform to the requirements, because the client TClientSocket buffer full? You can change the size of the buffer? Thank you very much!

CodePudding user response:

Unless you send data over the size of the buffer, you receive part of the code,

CodePudding user response:

 void __fastcall TServerForm: : ServerSocketClientRead (TObject * Sender, 
TCustomWinSocket * Socket)
{
RevNum=Socket - & gt; ReceiveLength ();
If (RevNum!
=3600){ShowMessage (" data reception error!" );
}
The Socket - & gt; ReceiveBuf (Buffer, 3600);
If (startflag==1)
WriteToCB ();//write ring buffer
CurvePlotThread - & gt; Resume ();//drawing thread
}

CodePudding user response:

Receive this part can't see what problem, check the sending part, not receiving the cache issue

CodePudding user response:

Send part is generated by the timer timing to send
 void __fastcall TClientForm: : SendTimerTimer (TObject * Sender) 
{
The switch (CurrentLinkStatus)
{
Case Break:
{
ShowMessage (" to connect to the server error, please connect again!" );
SendTimer - & gt; Enabled=false;
break;
}
In case the Link:
{
RandomGenerate ();
SendNum=ClientSocket - & gt; The Socket - & gt; SendBuf (& amp; RandomData, sizeof (RandomData));
If (SendNum!
=3600){SendErNum=WSAGetLastError ();
ShowMessage (" data error! Send bytes for "+ IntToStr (SendNum) +", the error code is "+ IntToStr (SendErNum));
}
break;
}
}
}

CodePudding user response:

I see you are a special function to send data, you with logging data and length, see if there are any problems, to locate the fault

CodePudding user response:

Send a set of data, wait for the best, too fast as if there will be a problem
  • Related