Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Re: TClientSocket write progress???
| Subject: | Re: TClientSocket write progress??? |
| Posted by: | "Bo Berglund" (bo.berglu..@telia.com) |
| Date: | Wed, 23 Jan 2008 19:51:15 |
On Tue, 22 Jan 2008 23:22:44 -0800, "Remy Lebeau \(TeamB\)"
<no.spam@no.spam.com> wrote:
>
>"Bo Berglund" <bo.berglund@telia.com> wrote in message
>news:ufncp3187nor6q3vqbmhsme40j8oflsv60@4ax.com...
>
>> Can this be done with a TClientSocket?
>
>Yes. You already know how many bytes you are asking TClientSocket to send,
>you know how many bytes it actually sends (the return value of SendBuf()),
>and you know the size of the file you are sending, so simply update your
>progress bar whenever you send a block of data.
Where can I do this? Is there an evant like OnSend or similar that I
have missed? How else can I get the info?
Remember I use the socket non-blocking.
I use Socket.SendText to send the string out and then I have to wait
for the response to come back from the other side as an acknowledge
that all is well.
I hade a look at the helpfile on Socket.OnWrite, but I really do not
understand what i am supposed to use this event for:
<quote>
Occurs when a client socket should write information to the socket
connection.
</quote>
and
<quote>
Write an OnWrite to write from the socket connection. If the socket is
a blocking socket, use a TWinSocketStream object to write to the
connection. Otherwise, use the methods of the Socket parameter to
perform the actual writing.
</quote>
I don't understand what this means, I have a big string and if I use
the *method* sendtext to send it out it all works fine.
But the method returns immediately (non-blocking) so I don't know when
it is actually done.
How can one write data in an event? How can the socket know when i
need to write data out?
Very confusing description.
>
>> Is there an event or similar that fires at certain amounts of
>> written bytes or similar?
>
>No.
>
>> If not, is it at all possible to have a progressbar when sending
>> multi-megabyte files?
>
>Of course.
>
>> Basically I need the same when receiving large files of course...
>
>In the OnRead event, you know how many bytes were received, and you
>(presumably) know the size of the file you are receiving, so simply update
>the progress bar whenever a block of data is received.
OK,
I already use OnRead to get the data and I put it into an internal
buffer until I find the ETX char that signals the end of transfer, so
presumably I could show some progress during this time, but I don't
know the final length of the data, though...
/BoB