// get size of file
infile.seekg (0,infile.end);
long nSize = infile.tellg();
infile.seekg (0);
char* buffer = new char[nSize];
// read content of infile
infile.read (buffer,nSize);
for(int i=0; i<nSize; i+=SEND_SIZE)
{
auto send_stream=make_shared<WsClient::SendStream>();
// write to outfile
int send_size = i< (nSize-SEND_SIZE) ? SEND_SIZE:(nSize-i);
cout << "Client: Sending binary: " << i << "," << send_size << endl;
send_stream->write(&buffer[i], send_size);
outfile.write (&buffer[i], send_size);
client.send(send_stream, nullptr, 130);
this_thread::sleep_for(chrono::milliseconds(200));
}
outfile.write (buffer, nSize);
// release dynamically-allocated memory
delete[] buffer;
infile.close();
outfile.close();
...
Client: Sending binary: 264000,8000
Client: Sending binary: 272000,8000
Client: Sending binary: 280000,8000
Client: Sending binary: 288000,8000
I also tried to use python websocket client to confirm delay is not because of network problem. Only
data sent by WsClient has long delay.
I am curious if I did anything wrong sort of caching the send buffer and not really sent right after I called client.send()?