Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with stream overflow

Reply
Thread Tools

Problem with stream overflow

 
 
Ciccio
Guest
Posts: n/a
 
      05-01-2006
I send file with ClientSocket and I receive with ServerSocket.
If I setting (ByteReceive == 5000) for prove and I overflow the stream.
How I send I file? Thanks.


SEND:
TMemoryStream *StreamName = new TMemoryStream;
StreamName->LoadFromFile("c:\\1.pdf");
StreamName->Seek(0,0);
if (StreamName) ClientSocket1->Socket->SendStream(StreamName);

RECEIVE:
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
TMemoryStream *Stream = new TMemoryStream;
int BufferSize = 1024;
BYTE *Buffer = new BYTE[BufferSize];
int ByteReceive;
static int val;

Stream->Seek(val,soFromBeginning);
ByteReceive = Socket->ReceiveBuf(Buffer,BufferSize);
Stream->Write(Buffer,BufferSize);
val += ByteReceive;
Memo1->Text = Stream->Size;

if (ByteReceive == 5000 ) {
Stream->Seek(0,soFromBeginning);
Stream->SaveToFile("c:\\2.pdf");
Stream->Clear();
delete Stream;
delete []Buffer;
val = 0;
}
 
Reply With Quote
 
 
 
 
Jonathan Mcdougall
Guest
Posts: n/a
 
      05-01-2006
Ciccio wrote:
> I send file with ClientSocket and I receive with ServerSocket.
> If I setting (ByteReceive == 5000) for prove and I overflow the stream.
> How I send I file? Thanks.


http://www.parashift.com/c++-faq-lit...t.html#faq-5.9


Jonathan

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DVD with subtitle stream to DivX with same subtitle stream(selectable) malise Software 1 04-17-2007 09:15 AM
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments