Well, std:string is just an array of bytes which you need to send. So, normally you establish the TCP connection as shown in the tutorial I mentioned before. After that you have opened TCP socket which works like stream. So you need to send all your bytes. You can allocate larger buffer for example 4kb like this:
ting::StaticBuffer<ting::u8, 4096> buf;
just check out docs for ting::Buffer, ting::StaticBuffer, ting::Array to know more about them.
Then you just copy data from your string to that buffer which you then pass on to the socket. So, you can send your 20mb by, for example, 4kb chunks, one after another.
But, check docs for TCPSocket::Send() to know how it works, it does not guarantee to send the whole buffer at once, it returns the number of bytes actually sent.
You should also know how to use ting::WaitSet in order to know when the socket is ready to send/receive the next portion of data. So, generally, you should get familiar with basic principles of how sockets work... I mean BSD sockets. ting::net is just a C++ wrapper for them, which makes many things easier, but you still have to understand the general things about sockets, and about select() function (this is what ting::WaitSet for).
So, if you have problems making your code to work, then just post here your code snippet which does not work and then I might see what is wrong in how you use ting::net and help you.
--
Ivan
ting::StaticBuffer<ting::u8, 4>
пятница, 26 июля 2013 г., 15:49:59 UTC+3 пользователь Rafik Abdulwahab написал: