c++ sending big data through socket in 1 packet -
is there way guide os (win7) send big data (3mb , such), in 1 packet c++ sockets?
i mean sending data "send" function without seperate data lot of packets:
iresult = send( connectsocket, &vect[0], vect.size(), 0 ); // sending file (im trying send png file sized 3mb through sockets). thanks.
given length field of ip packet 2 bytes, no. stream broken packets of @ 65k. since tcp stream protocol implementation how packets formatted , sent. guaranteed data sent in order sent it.
if want know end of sent data is, consider sending data size first reading amount of data.
unsigned int len = vect.size(); iresult = send( connectsocket, &len, sizeof(len), 0 ); // sending length iresult = send( connectsocket, &vect[0], vect.size(), 0 ); // sending file then on receiving side:
unsigned int len; iresult = recv(socket, &len, sizeof(len), 0); // know how data read png also note, should check how sent during each call send since not have send entire buffer in single call. same recv. may have call recv multiple times read entire sent data.
Comments
Post a Comment