Re: [twsocket] Download time

2005-09-02 Thread Angus Robertson - Magenta Systems Ltd
> You can also use TDateTime, but if the clock on your computer is 
changed
> during time-measuring, you would get the wrong values.

Which is a very good reason for not using it!  And all the floating 
point arithmetic and conversion from system time is much slower. 

QueryPerformanceCounter can be used for periods longer than 49 days, 
but it's 64-bit arithmetic which I think is the FPU again.  Provided 
GetTickCount is used with functions that check for wrap around, and you 
don't want to measure more than 49 days, it's quite safe. And with a 
special function that allows the wrap around to be tested!

Angus

function DiffTicks (const StartTick, EndTick: longword): longword ;
begin
if EndTick > StartTick then
Result := EndTick - StartTick
else
Result := (MaxLongWord - StartTick) + EndTick ;
end ;
 
function GetTickCountX: longword ;
var
newtick: Int64 ;
begin
result := GetTickCount ;
if TicksTestOffset = 0 then exit ;  // no testing, byebye

// TicksTestOffset is set in initialization so that the counter wraps 
// five mins after startup 
newtick := Int64 (result) + Int64 (TicksTestOffset) ;
if newtick >= MaxLongWrd then
result := newtick - MaxLongWrd
else
result := newtick ;
end ;

// force GetTickCount wrap in 5 mins - next line normally commented out
TicksTestOffset := MaxLongWord - GetTickCount - (5 * 60 * 1000) ;

Angus
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Download time

2005-09-02 Thread Arno Garrels
Angus Robertson - Magenta Systems Ltd wrote:
>> I am unfamiliar with GetTickCount.  Is that an API or something?
> 
> it also wraps after 49 days, so
> some care is needed for applications that run longer without a reboot.

For calculating ticks elapsed I use this function:

function CalcTicksAppart(const T1: DWORD): DWORD;
var
T2 : DWORD;
begin
T2 := GetTickCount;
if T2 >= T1 then
Result := T2 - T1
else
Result := MAXDWORD - T1 + T2;
end;
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Download time

2005-09-02 Thread Bjørnar Nielsen
> GetTickCount returns milliseconds since Windows booted. It's 
> a core Windows API used for most application timing, although 
> it only has a resolution of about 20ms (I think), it also 
> wraps after 49 days, so 
> some care is needed for applications that run longer without 
> a reboot.   
> 

You can also use TDateTime, but if the clock on your computer is changed
during time-measuring, you would get the wrong values.

Regards Bjørnar


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Download time

2005-09-02 Thread Angus Robertson - Magenta Systems Ltd
> I am unfamiliar with GetTickCount.  Is that an API or something? 

GetTickCount returns milliseconds since Windows booted. It's a core 
Windows API used for most application timing, although it only has a 
resolution of about 20ms (I think), it also wraps after 49 days, so 
some care is needed for applications that run longer without a reboot.   

   StartTick := GetTickCount ;
// do something
   Seconds := (GetTickCount - StartTick) div 1000 ;

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Download time

2005-09-02 Thread G. M. Faggiano

Thank you for your reply.

I am unfamiliar with GetTickCount.  Is that an API or something?  It
doesn't seem to be associated with THttpCli.  Can you give me a small
example of how to use GetTickCount.

Thank you.


> I'm using a ThttpCli to download a 500kb file from my server.  I could
> go bigger, but I have a 6000mb transfer limit per month on my server.
I
> would rather do this another way, but this is the only way I know of.
> Still, doing it this way, I can't figure out how to determine the time
> it took to download the file.  I hope this makes sense to someone.

Use GetTickCount just before starting your download and GetTickCount
from the OnRequestDone event.
You'll have an exact measure of the time in milli-seconds (be aware
GetTickCount wrap back to 0
after approximatively 49 days of up time). Given the size of the
download you've done, you can
compute the thruput with very simple math.

You can also start a download of a large file and stop it after, let's
say 15 seconds using Abort.
Looking at the received size during 15 seconds, you can compute the mean
thruput during those 15
seconds.

--
[EMAIL PROTECTED]
http://www.overbyte.be

- Original Message - 
From: "G. M. Faggiano" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, September 01, 2005 3:58 AM
Subject: [twsocket] Download time


> Hello,
>
> I'm trying to write a little app that downloads a file from my server
at
> regular intervals and tells me what my true connection speed is.
> I'm doing this because I use a broadband connection through my lan.
So,
> I have no real way to check my current speed without going to one of
> those online speed tests.  I just want to represent my speed in mps
via
> an icon in my system tray.  If anyone has a better Idea on how to get
> the result I'm after, please tell me.  Here is what I'm doing now.
>
> I'm using a ThttpCli to download a 500kb file from my server.  I could
> go bigger, but I have a 6000mb transfer limit per month on my server.
I
> would rather do this another way, but this is the only way I know of.
> Still, doing it this way, I can't figure out how to determine the time
> it took to download the file.  I hope this makes sense to someone.
>
> Also, Francois, your components are awesome!  I've been using them for
> about two years now.  I'll be sure to send you a post card.
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be



-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] FHtmlCharSet property of THtmlSmtpCli

2005-09-02 Thread Bjørnar Nielsen
> I have seen but had not time yet to examine the problem.

Thanks.

You will understand the problem in a minute or so when examining. There is a
FHtmlCharSet wich is used for the html-part, but there is no way of setting
the value unless you derive the component. I just made a set-er an get-er
for it.

Regards Bjørnar


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NO_ADV_MT symbol

2005-09-02 Thread Francois Piette
> > IMO it is better design to have all access to a given
> > component from only one thread. And in that case, you can
> > define NO_ADV_MT to have better performances because you
> > avoid using a critical section.
>
> Thank you, this answers my questions.
>
> I use 2 servers and some clients in same exe, but seperate threads. Atually
> all is controlled from main, but only by posting messages, so no threads or
> components in them is touched from outside the thread. And no
> sockets/components is switched from one thread to another.
>
> I will then define the NO_ADV_MT and I will get improved performance?

You should. Improvement will be significant if you have a slow processor and a 
fast network. It will
be neglectible if you have a fast processor and slow network.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] FHtmlCharSet property of THtmlSmtpCli

2005-09-02 Thread Francois Piette
I have seen but had not time yet to examine the problem.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


- Original Message - 
From: "Bjørnar Nielsen" <[EMAIL PROTECTED]>
To: "'ICS support mailing'" 
Sent: Friday, September 02, 2005 1:07 PM
Subject: Re: [twsocket] FHtmlCharSet property of THtmlSmtpCli


> Did anyone see my message below from a week ago?
>
> I guess the property I made should be moved from published to proteced.
>
> Regards Bjørnar
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Bjørnar Nielsen
> > Sent: 26. august 2005 12:59
> > To: 'ICS support mailing'
> > Subject: [twsocket] FHtmlCharSet property of THtmlSmtpCli
> >
> > I use THtmlSmtpCli for sending email with html content. I use
> > the format UTF-8, and I set this on the published
> > CharSet-property, but this charset is only set for the
> > plain-text-part. I notised the component has a not published
> > property FHtmlCharSet.
> >
> > Either this property should copy its contents from FCharSet,
> > or the property should be published to be able to set the
> > CharSet other than default value.
> > In my own code I made it published. I put the folowing lines
> > of code on line
> > 761 in SmtpProt.pas.
> >
> > property HtmlCharSet  : String read  FHtmlCharSet {Bjornar}
> >write FHtmlCharSet;{Bjornar}
> >
> > Francois, could you merge this to your working copy or
> > comment if this should be done differently?
> >
> > Regards Bjørnar
> >
> >
> > --
> > To unsubscribe or change your settings for TWSocket mailing
> > list please goto http://www.elists.org/mailman/listinfo/twsocket
> > Visit our website at http://www.overbyte.be
> >
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] [TMimeDec] Beta version to test

2005-09-02 Thread Angus Robertson - Magenta Systems Ltd
> > And what was the cause? In TMimeDecEx you set destination stream 
> > after the part was decoded. You lose your data, because you don't 
> > save it:
> > Hope this helps... :)
> 
> Not really, you say there's bug in TMimeDecEx, but you don't say what 
> you changed to get your 'result'.  

No response to my comments.  This means either:

1 - the TMimeDec beta is buggy and should not be released.

2 - the TMimeDec beta is not backward compatible with existing 
applications, and should not be released. 

If I've made a simple error in TMimeDecEx, please tell me what it is, 
and why it's able to correctly decode all content parts except the 
last, which is always empty, using the same events, yet works fine with 
the old TMineDec. 

Angus
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] FHtmlCharSet property of THtmlSmtpCli

2005-09-02 Thread Bjørnar Nielsen
Did anyone see my message below from a week ago?

I guess the property I made should be moved from published to proteced.

Regards Bjørnar 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Bjørnar Nielsen
> Sent: 26. august 2005 12:59
> To: 'ICS support mailing'
> Subject: [twsocket] FHtmlCharSet property of THtmlSmtpCli
> 
> I use THtmlSmtpCli for sending email with html content. I use 
> the format UTF-8, and I set this on the published 
> CharSet-property, but this charset is only set for the 
> plain-text-part. I notised the component has a not published 
> property FHtmlCharSet.
> 
> Either this property should copy its contents from FCharSet, 
> or the property should be published to be able to set the 
> CharSet other than default value.
> In my own code I made it published. I put the folowing lines 
> of code on line
> 761 in SmtpProt.pas.
> 
> property HtmlCharSet  : String read  FHtmlCharSet {Bjornar}
>write FHtmlCharSet;{Bjornar}
> 
> Francois, could you merge this to your working copy or 
> comment if this should be done differently?
> 
> Regards Bjørnar
> 
> 
> --
> To unsubscribe or change your settings for TWSocket mailing 
> list please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> 


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NO_ADV_MT symbol

2005-09-02 Thread Bjørnar Nielsen
> IMO it is better design to have all access to a given 
> component from only one thread. And in that case, you can 
> define NO_ADV_MT to have better performances because you 
> avoid using a critical section.

Thank you, this answers my questions.

I use 2 servers and some clients in same exe, but seperate threads. Atually
all is controlled from main, but only by posting messages, so no threads or
components in them is touched from outside the thread. And no
sockets/components is switched from one thread to another.

I will then define the NO_ADV_MT and I will get improved performance?

Regards Bjørnar


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NO_ADV_MT symbol

2005-09-02 Thread Francois Piette
> I wonder when it is safe to define NO_ADV_MT.
>
> Must I not define NO_ADV_MT at all when I use threads?
>
> What if I use a socketserver in one thread and another socketserver in
> another thread  and there is no interaction between the threads? The client
> connections always stays within the threads.
>
> Or, what if I use a httpcli in one thread, and a another httpcli in another
> thread, and there is no interaction between the threads?

it is safe to define NO_ADV_MT when a TWSocket instance is use from a single 
thread only. Every call
to method, every property use, every event handler must be run within the 
context of the same thread
(either the creation thread or any other thread after calling ThreadAttach). No 
problem to have an
instance in one thread and another instance in another thread.

IMO it is better design to have all access to a given component from only one 
thread. And in that
case, you can define NO_ADV_MT to have better performances because you avoid 
using a critical
section.

The usual case where no must not define NO_ADV_MT is when you have a TWSocket 
created (or attached)
in a thread context and having call to Send and Receive from other threads.


--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] NO_ADV_MT symbol

2005-09-02 Thread Bjørnar Nielsen
I wonder when it is safe to define NO_ADV_MT.
 
Must I not define NO_ADV_MT at all when I use threads?
 
What if I use a socketserver in one thread and another socketserver in
another thread  and there is no interaction between the threads? The client
connections always stays within the threads.
 
Or, what if I use a httpcli in one thread, and a another httpcli in another
thread, and there is no interaction between the threads?
 
 
Regards Bjørnar
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be