Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Re: TClientSocket write progress???

www.cryer.info
Managed Newsgroup Archive

Re: TClientSocket write progress???

Subject:Re: TClientSocket write progress???
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Wed, 23 Jan 2008 12:19:20

"Bo Berglund" <bo.berglund@telia.com> wrote in message
news:s12fp3trrrr9cepacr0mpr7iuvicskjfpa@4ax.com...

> Where can I do this?

Do it whereever you are performing the actual send.

> Is there an evant like OnSend

No.

> Remember I use the socket non-blocking.

Not relevant.  At some point, you have to send a block of your data to the
socket.  So just update your progress info at that same point in the code.

> I use Socket.SendText

SendText() returns the number of bytes actually passed to the socket.  If
the return value is less than the length of the string, you have to call
SendText() again to resend the remaining characters.  If SendText()
returns -1 for a non-blocking socket, then the socket's internal buffer is
full and you have to wait until the OnWrite event is triggered before you
can pass more data to the socket.  So you will just have to store the rest
of your data to a separate buffer, and then flush the buffer to the socket
at a later time.  Go to http://www.deja.com and search the newsgroup
archives.  I have posted examples of using the OnWrite event several times
before.

> 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:

That event is not used for progress tracking.  It is used as a notification
to tell you when the socket is allowed to accept new outbound data after
entering a blocking state.

> But the method returns immediately (non-blocking) so I don't
> know when it is actually done.

There is no way to know when a send is actually performed by the socket.
When you pass data to SendText() or SendBuf(), the data is put into an
internal buffer that the socket sends in the background at its leisure.
SendText/Buf() report back to you how many bytes were put into the buffer,
not how many bytes were transmitted.  There is no way to get that
information.

> 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...

Then all you can show is the number of bytes that are received, but not the
percentage of how far along the transfer is, or how long it is expected to
finish.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive