Home > other >  Winsock control according to the data byte received
Winsock control according to the data byte received

Time:10-03

Winsock control in the use of VC as a server to receive data from the client, if according to the form of a string to receive, and some have no way to display as a string, lead to loss of data, how to use the GetData () function in the manner of bytes to read data, read data stored in a buffer, and then I will read all of the data in bytes?

Void CEFADlg: : DataArrivalWinsock1 (long bytesTotal)
The VARIANT vtType vtLen;
COleVariant Data;

VtType. N=VT_UI1;
VtType. BVal=VT_BSTR;//the feeling is out of the question here
VtLen. LVal=bytesTotal;
M_server. GetData (& amp; Data, vtType vtLen);

Char * buf=Data. PcVal;
Char * p=buf.
Cstrings STR, str1;
int i;
for(i=0; i{
Str1. The Format (" % X ", * (p++));
STR +=str1;
}
MessageBox (STR);
The results of the actual operation is
73 0 0 0 0 0 0 49 74 72 61 74 3 f 49 0 3 0 0 f 49 49 0 0 0 3 f 3 0 f
With the content of the network debugging assistants received is this:
49 73 74 61 72 74 92 24 49 49 24 49 24 49 92 92 92 92 24 24 49 92 24 65 6 e 64
Network debugging assistant data received is for
Use a machine to receive data with 0 and receiving is not complete, should be how to solve?
Idea is that the data in the manner of bytes of receiving, not according to the string, specific how to implement?
  • Related