Zvone wrote: > A few POP3 related questions... > > 1. How am I supposed to detect when POP3 component has disconnected or > what state is it in?
OnSessionClosed is the event to initiate a reconnect delayed (see below). > OnSessionClosed appears to trigger BEFORE it disconnects but after > QUIT is sent (not logical for me, should be the last one to trigger) > and what seems to trigger at the disconnection time is OnRequestDone > when TPop3Request is pop3Quit which appears to be the last one to > happen. But if I immediately during this event start new batch of POP3 > commands (by setting new server, new port etc.) it may sometimes > trigger "pop3 already connected" and sometimes won't. So obviously it > is still connected. Yes, one cannot rely on these events always trigger in the same order. Also it might happen that you get a response to the QUIT request but the server doesn't close the connection. In this case after some timeout exceeded you have to close the connection yourself. In latest ICS V7 there's an basic timeout feature implemented in TWSocket that you could use for this purpose, this feature has to be explicitly enabled by setting conditional define "EXPERIMENTAL_TIMEOUT" in OverbyteIcsDefs.inc. When built with "EXPERIMENTAL_TIMEOUT" TPop3Cli.CtrlSocket will get three new properties and one new event: property TimeoutSampleInterval: LongWord property ConnectTimeout: LongWord property IdleTimeout: LongWord property OnTimeout: TTimeoutEvent > Also, is it good to fill pop3 component with new server name while in > event handler or how to implement a small time-delay (to fill it right > after the event is handled)? The correct way to reconnect (delayed) is: In the OnSessionClosed event handler post a custom Windows message to some Window or to the form handle and from the message handler populate properties and start the next session. [schnip] > I could start 2-3 pop3 components for 2-3 servers rather than waiting > for first one to finish, but that is rather dumb idea if protocol > state can be detected. No problem to have multiple instances, you can use the same event handlers for all instances, just use the "Sender" argument and cast it to, for instance, TPop3Cli. > > 2. What good is TimeOut property for? It is obviously not for timeout > like for example waiting for server response because you have to use > TTimer for that. I also tried to see if it will be used for DNS lookup > or something like that but it doesn't seem to have any effect... This timeout only works (if at all) with the synchronous methods or TSyncPop3Cli. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be