I
ishmael4
I dont know what to do with this function. It separates a block of binary
data into [max_pkg_data] blocks, and then deals with the rest of binary (les
than 5000 bytes).
Here we go:
--cut here--
void SendBinary(binary& sent, int status)
{
unsigned int n=0;
for (n=0;n<sent.size/max_pkg_data;++n)
{
pkg nPkg;
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data); //(1)
nPkg.info=0;
nPkg.size=max_pkg_data;
//debug info//
String a(nPkg.data);
int i=a.Length(); //(2)
//debug info//
Form1->SS1->Socket->Connections[0]->SendBuf((void*)&nPkg,sizeof(pkg));
}
pkg nPkg;
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=status;
nPkg.size=sent.size-((n)*max_pkg_data);
//debug info//
String a(nPkg.data);
int i=a.Length(); // (3)
//debug info//
Form1->SS1->Socket->Connections[0]->SendBuf((void*)&nPkg,sizeof(pkg));
return;
}
--cut here--
BUT after executing (1), debug info (2) gives me size 5003. So 3 more bytes
are copied into nPkg.data. I dont know why, esspecially that after memcpy()
after the loop is executed, (3) gives me right size. And if I put:
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data-3); //(1)
it (2) gives me the exact size, 4997 bytes. Why?
Please help me.
data into [max_pkg_data] blocks, and then deals with the rest of binary (les
than 5000 bytes).
Here we go:
--cut here--
void SendBinary(binary& sent, int status)
{
unsigned int n=0;
for (n=0;n<sent.size/max_pkg_data;++n)
{
pkg nPkg;
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data); //(1)
nPkg.info=0;
nPkg.size=max_pkg_data;
//debug info//
String a(nPkg.data);
int i=a.Length(); //(2)
//debug info//
Form1->SS1->Socket->Connections[0]->SendBuf((void*)&nPkg,sizeof(pkg));
}
pkg nPkg;
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=status;
nPkg.size=sent.size-((n)*max_pkg_data);
//debug info//
String a(nPkg.data);
int i=a.Length(); // (3)
//debug info//
Form1->SS1->Socket->Connections[0]->SendBuf((void*)&nPkg,sizeof(pkg));
return;
}
--cut here--
BUT after executing (1), debug info (2) gives me size 5003. So 3 more bytes
are copied into nPkg.data. I dont know why, esspecially that after memcpy()
after the loop is executed, (3) gives me right size. And if I put:
memcpy(&nPkg.data[0],&sent.buffer[n*max_pkg_data],max_pkg_data-3); //(1)
it (2) gives me the exact size, 4997 bytes. Why?
Please help me.