Hi All,
I have a 2GB file.Iam trying to collect that file using FTP.
Below is the code

const unsigned long FTPClient::getFile(TCPSocket* theTransferSocket,
ostream& theLocalStream) const
unsigned long tbr = 0; // Total bytes received.
tbr = getBinaryFile(theTransferSocket, theLocalStream);
if (!theLocalStream) { cerr<<"output stream failed "<<endl;
throw FTPException("Error on output stream."); }
cerr<<" number of bytes read in getFile() tbr="<<tbr<<endl;
return tbr;


const unsigned long FTPClient::getBinaryFile(TCPSocket* theTransferSocket,
ostream& theLocalStream) const
throw (FTPException&)
cerr<<"==getBinaryFile() =="<<endl;
static const int TMP_BUFSIZ = 2048;
char tmpBuffer[TMP_BUFSIZ];
unsigned long tbr = 0; // Total bytes read.
unsigned long nobr = 0; // No. of bytes read.

while((nobr =
theTransferSocket->read( tmpBuffer, TMP_BUFSIZ, myTimeOut )) > 0)
theLocalStream.write(tmpBuffer, nobr);
tbr += nobr;
cerr<<"==changed to unsigned long int=="<<endl;
cerr<<"== Total bytes read = "<<tbr<<endl;
catch (SocketException& theExc) {
theExc.addReason("Failed to receive binary buffer.");
throw FTPException(theExc);
if( nobr == -1 )
throw FTPException( "Failed to receive BINARY file. Socket timed out.", AlarmType::FTP_TIMEOUT );
cerr<<"==b4 end of getBinaryFile() =="<<endl;
cerr<<"== Total bytes read = "<<tbr<<endl;
return tbr;

when execute the above snippet...
it is saying
== Total bytes read = 2998908000
output stream failed

the file size is same as above
but iam not able to find why that ostream is getting failed ....
after reading all bytes.

Could you find any hints and let me know if you have any