Hello, I'm using your SmtpClient component for sending e-mails. I'm trying to built in a failover in my application so that if the first configured mail server can't be reached a second etc. will be tried.
The problem is now that I like to cancel the connect if it takes too long. timeout:=timeout+text.Count*10; for i := 0 to length(emailservers) - 1 do begin with datenmodul.SmtpCli do begin try // setup e-mail parameters like server and content mailerror:=0; mailerrortext:=''; isemail_connection:=true; Connect; except mailerror:=1; mailerrortext:=ErrorMessage; try datenmodul.SmtpCli.Quit; except end; continue; end; end; // wait for timeout or success t:=GetTickCount; while ((isemail_connection = true) and (mailerror = 0)) and (((GettickCount >= t) and (GetTickCount-t < timeout)) xor ((GettickCount < t) and (t-GetTickCount < timeout))) do begin sleep(10); Application.ProcessMessages; end; // in case of error disconnect asap if (mailerror <> 0) or (isemail_connection = true) then begin try // datenmodul.SmtpCli.Abort; doesn't work better! datenmodul.SmtpCli.CtrlSocket.cose; except end; end else begin try if datenmodul.SmtpCli.Connected then datenmodul.SmtpCli.Abort; except end; break; end; end; The OnRequestDone is nearly your demo code (the output has been disabled and the case has been packed into a try/except block. I do get 10004 errors or "component not ready". It works now since I packed it into try/except blocks but I wonder if this will make further problems. The problems only occur if the first e-mailserver is bot reachable and the connection has to be cancelled. This is in a normal function which makes it blocking for the direct caller but since it's part of a COM-server the COM server could do some things internally while trying to send this e-mail. Greetings Markus PS: somebody should document this component in the wiki, obviously not me! ;-) -- 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