How can I flush a stream through a socket?
David Mathews
grnbriar at mindspring.com
Sun Jul 1 10:49:43 PDT 2007
I have a stream and socket based file transfer running (for large
image files).
But the last partial file section is always dropped. I get an exact
size of bytes on disk and in the file, and it is too small. The extra
has been dropped.
I'm trying to do this with streams if at all possible. These files
are already compressed, so I don't need the zlib stream as shown in
the example I could find.
Everything works fine except for the tail of every file.
I've tried both File and FFile steams.
How can I get the last of the file to flush through the stream?
David
wxWidgets 2.8
// Client side
sock->Write(CurFileName,256);
wxFileInputStream * File = new wxFileInputStream(CurFile);
wxSocketOutputStream *SockOut = new wxSocketOutputStream(*sock);
SockOut->Write(*File);
SockOut->Sync();
SockOut->Close();
delete SockOut;
delete File;
sock->Destroy();
//Server Side
sock->Read(name,256);
strcpy(newfile,TextureFolder); // user selected local folder to
receive files
#ifdef _WIN32
strcat(newfile,"\\");
#else
strcat(newfile,"/");
#endif
strcat(newfile,name);
wxFileOutputStream File(newfile);
wxSocketInputStream SockIn(*sock);
File.Write(SockIn);
File.Sync();
File.Close();
More information about the wx-users
mailing list