From what I understand in your post, you are breaking your 2MB of data into small packets, prefacing each packet with a header indicating perhaps packet-size and perhaps with a packet-sequence-number or some other identifying ID. You are then sending these packets through a TCP socket to another application.
This is typically the way it is done. If the recipient of the data is on the same host system, then perhaps there are alternatives to providing the data. Otherwise, what you have described is fine.
What compelled you to post a query here on the forum? Is something not working as expected?
P.S. If you have development control over the application that is receiving the data, perhaps you can use the following C++ code on it and on your application. If you are programming in a different language, look for the equivalent library calls. Btw, I do not know if these setting will work; I've never had a need to test it.
Code:
////////////////////////////////////////////////////////////////////////////////
//
// Method: SetSendBufferSize
//
////////////////////////////////////////////////////////////////////////////////
void
Socket::SetSendBufferSize(unsigned int size)
{
if (setsockopt(m_Socket, SOL_SOCKET, SO_SNDBUF, (void *) &size, sizeof(size)) < 0)
{
throw std::runtime_error("Could not set SendBufferSize for socket!");
}
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: SetRecvBufferSize
//
////////////////////////////////////////////////////////////////////////////////
void
Socket::SetRecvBufferSize(unsigned int size)
{
if (setsockopt(m_Socket, SOL_SOCKET, SO_RCVBUF, (void *) &size, sizeof(size)) < 0)
{
throw std::runtime_error("Could not set RecvBufferSize for socket!");
}
}
Bookmarks