473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem with stream overflow

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;
}
May 1 '06 #1
1 2278
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

May 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Stewart Gordon | last post by:
Using g++ 3.1, Mac OS X. I'm doing something trying to involve a null output stream, i.e. a stream that just discards what goes into it. The idea is that it gives a simple way of producing...
6
by: William Payne | last post by:
Hi, I have a function declared as: void foo(const std::string& s, std::ostream& verbose_output); I want foo() to write a lot of data to the ostream if it's a valid stream. If it's valid or not...
7
by: Lee | last post by:
Hi, I'm a stream virgin and am attempting to output strings to a file. My approach is to write the string initially to a 'stringstream' and only when complete write the stringstream to the file...
0
by: Ciccio | last post by:
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...
1
by: Derek | last post by:
>From reading countless posts here I seem to get the impression that to roll your own output stream class, the minimum you would likely needed to do would be to override the overflow() method, as...
22
by: Wilson | last post by:
i am learning to program using c++ and was set a task of making a simple encryption algorithim. I choose to start with one where simply each letter is replaced with its equivilent in the alphabet...
33
by: john | last post by:
I am reading TC++PL3 and in "21.3.3 Stream State", 4 member functions returning bool are mentioned: template <class Ch, class Tr= char_traits<Ch class basic_ios: public ios_base { public: //...
4
by: rakesh.usenet | last post by:
For a particular application of mine - I need a simulation of byte array output stream. * write data onto a stream * getback the contiguous content as an array later for network transport. ...
10
by: hsmit.home | last post by:
Hi everyone, I'm having some difficulty with the following piece of code. I have stripped it to it's bare minimum to demonstrate the problem at hand. Compiler: MS Visual C++ 2005 Express...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.