Re: [twsocket] OnDataAvailable and Reetrancy
Markus Humm wrote: I don't call processmessages and the like directly in the event but might output some lines on screen for debugging. How? ShowMessage is a modal form. Other thing: what about critical sections. Would they be safe for preventing this in my situation? No, critical sections would be working only when they are used from multiple threads. You could try something like below, is the exception raised? var AFlag:Boolean procedure TForm.WSocketDataAvailable(Sender: TObject; ErrCode: Word); begin if AFlag then raise Exception.Create('reentered'); AFlag := TRUE; try [..] finally AFlag : FALSE end; end; --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Greetings Markus -- 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] OnDataAvailable and Reetrancy
I don't call processmessages and the like directly in the event but might output some lines on screen for debugging. Could the VCL maybe call getmessage etc. behind my back in this scenario? You can safely add a line to a memo. You can't display a dialog box or a modal form. You can detect reentrancy in OnDataAvailable using a global variable. And you can see where the reentrancy come from using the debugger and his call stack display. 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: Markus Humm [EMAIL PROTECTED] To: twsocket@elists.org Sent: Friday, September 01, 2006 7:25 AM Subject: [twsocket] OnDataAvailable and Reetrancy Can OnDataAvailable be called while it is already running? And if yes, how to prevent this? Is using critical sections a good idea here? You must avoid having the events reentered. To avoid this, you simply have to _not_ call any form of the message pump from the events. The message pump is ProcessMessages, any modal form, GetMessage/DispatchMessage and the likes. I don't call processmessages and the like directly in the event but might output some lines on screen for debugging. Could the VCL maybe call getmessage etc. behind my back in this scenario? Other thing: what about critical sections. Would they be safe for preventing this in my situation? Greetings Markus -- 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] Handling redirects
When this event is called, where can I get the new url? I need it to change the url I keep on file. Unfortunately the URL property does not get updated. thanks, Mike On 2/7/06, Francois Piette [EMAIL PROTECTED] wrote: Assuming you use THttpCli, there is a property called FollowRedirection. Set it to true. 1. Did you mean FollowRelocation? 2. Does it automatically then handle the redirection. Or will it trigger the OnLocationChange event where I need to get the new Destination to use? OnLocationChange is always triggered. If ou need to change the relocation the set FollowRelocation to FALSE and run a new request yourself with the url you want to relocate to. -- [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 -- 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] OnDataAvailable and Reetrancy
But TWSocket will swallow the exception, so use this: var AFlag:Boolean procedure TForm.WSocketDataAvailable(Sender: TObject; ErrCode: Word); begin try if AFlag then raise Exception.Create('reentered'); AFlag := TRUE; try [..] finally AFlag : FALSE end; except on E: Exception do ShowMessage(E.Message); // or WriteLn or add to Memo or whatever end; end; --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Friday, September 1, 2006, 08:15, Arno Garrels wrote: Markus Humm wrote: I don't call processmessages and the like directly in the event but might output some lines on screen for debugging. How? ShowMessage is a modal form. Other thing: what about critical sections. Would they be safe for preventing this in my situation? No, critical sections would be working only when they are used from multiple threads. You could try something like below, is the exception raised? var AFlag:Boolean procedure TForm.WSocketDataAvailable(Sender: TObject; ErrCode: Word); begin if AFlag then raise Exception.Create('reentered'); AFlag := TRUE; try [..] finally AFlag : FALSE end; end; --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Greetings Markus -- 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] SMTPClient
Hi Bevan Thanks for your response. I have corrected that but continues giving error. The first time that execute it, it connects but it fails in Data. The second time, it passes Connect and Data and it fails in Quit but I don't receive mail. I have tested with server 127.0.0.1 or localhost and it is the same. Can you help me? Regards. Carlos. - Original Message - From: Bevan Edwards [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Thursday, August 31, 2006 4:13 PM Subject: Re: [twsocket] SMTPClient Hi Carlos, Is the Smtp1.port := 'smpt'; an error in your code or a typo? It should be Smtp1.port := 'smtp'; Regards, Bevan lalin wrote: Hello, I use SMTPClient for sending a email since a server with default smtp server of IIS. The example program find this smtp server. But in my program, with this code: Smtp1.Host := smtpserver; Smtp1.port := 'smpt'; Smtp1.FromName := name; Smtp1.HdrFrom := mail1; Smtp1.HdrTo:= mail2; Smtp1.HdrSubject := title; Smtp1.Connect; Smtp1.Data; Smtp1.quit; produces SMTP component not ready. Can you help me? Regards. Carlos. -- 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
[twsocket] Some updates and a new component
Hello, 1) FTP c/s 64-bit stream support reworked and tested: a) http://www.duodata.de/misc/delphi/new-ics5-20060901.zip (includes latest changes from Angus Robertson) b) http://www.duodata.de/misc/delphi/new-ics6-20060901.zip (latest changes from Angus Robertson are still missing) 2) TSmtpCli supporting NTLM authentication: http://www.duodata.de/misc/delphi/SmtpProt_08132006.zip 3) A small STUN client component implementing rfc3489: http://www.duodata.de/misc/delphi/Ics5-StunCli-03.zip Included is a small demo, it's not required to install the component, just unzip any file to the same directory and you are ready to go. 4) Added RFC-2782 support to HLembke\TDnsQuery: http://www.duodata.de/misc/delphi/new-Ics5-HLembke-DnsQuery.zip Included is an updated version of the demo. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- 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] SMTPClient
produces SMTP component not ready. Can you help me? As another message already said, you are trying to use an asynchronous (non-blocking) component as a synchronous component. Either revise you way of doing thing or use the sync version of the component. It is better to revise your programming model and use the asynchronous model. That is use the events. Look at MailSnd sample program delivered with ICS. Look at the code behind All In One button which show how to use the events to chain all operations required to send emails. Once you had a look at the sample, don't hesitate to ask for more questions. 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: lalin [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, September 01, 2006 12:08 PM Subject: Re: [twsocket] SMTPClient Hi Bevan Thanks for your response. I have corrected that but continues giving error. The first time that execute it, it connects but it fails in Data. The second time, it passes Connect and Data and it fails in Quit but I don't receive mail. I have tested with server 127.0.0.1 or localhost and it is the same. Can you help me? Regards. Carlos. - Original Message - From: Bevan Edwards [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Thursday, August 31, 2006 4:13 PM Subject: Re: [twsocket] SMTPClient Hi Carlos, Is the Smtp1.port := 'smpt'; an error in your code or a typo? It should be Smtp1.port := 'smtp'; Regards, Bevan lalin wrote: Hello, I use SMTPClient for sending a email since a server with default smtp server of IIS. The example program find this smtp server. But in my program, with this code: Smtp1.Host := smtpserver; Smtp1.port := 'smpt'; Smtp1.FromName := name; Smtp1.HdrFrom := mail1; Smtp1.HdrTo:= mail2; Smtp1.HdrSubject := title; Smtp1.Connect; Smtp1.Data; Smtp1.quit; produces SMTP component not ready. Can you help me? Regards. Carlos. -- 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] Handling redirects
It is in the location property if memory is stille alive. 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: Mike Versteeg [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, September 01, 2006 11:39 AM Subject: Re: [twsocket] Handling redirects When this event is called, where can I get the new url? I need it to change the url I keep on file. Unfortunately the URL property does not get updated. thanks, Mike On 2/7/06, Francois Piette [EMAIL PROTECTED] wrote: Assuming you use THttpCli, there is a property called FollowRedirection. Set it to true. 1. Did you mean FollowRelocation? 2. Does it automatically then handle the redirection. Or will it trigger the OnLocationChange event where I need to get the new Destination to use? OnLocationChange is always triggered. If ou need to change the relocation the set FollowRelocation to FALSE and run a new request yourself with the url you want to relocate to. -- [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 -- 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] Handling redirects
Yes, that's correct. Thanks. PS: I will gladly pay a few dollars for a good help file :) Mike On 9/1/06, Francois Piette [EMAIL PROTECTED] wrote: It is in the location property if memory is stille alive. 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: Mike Versteeg [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, September 01, 2006 11:39 AM Subject: Re: [twsocket] Handling redirects When this event is called, where can I get the new url? I need it to change the url I keep on file. Unfortunately the URL property does not get updated. thanks, Mike On 2/7/06, Francois Piette [EMAIL PROTECTED] wrote: Assuming you use THttpCli, there is a property called FollowRedirection. Set it to true. 1. Did you mean FollowRelocation? 2. Does it automatically then handle the redirection. Or will it trigger the OnLocationChange event where I need to get the new Destination to use? OnLocationChange is always triggered. If ou need to change the relocation the set FollowRelocation to FALSE and run a new request yourself with the url you want to relocate to. -- [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 -- 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] Handling redirects
Mike Versteeg wrote: PS: I will gladly pay a few dollars for a good help file :) Source code is the best help file you can get, it even describes the bugs ;-) --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Mike On 9/1/06, Francois Piette [EMAIL PROTECTED] wrote: It is in the location property if memory is stille alive. 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: Mike Versteeg [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, September 01, 2006 11:39 AM Subject: Re: [twsocket] Handling redirects When this event is called, where can I get the new url? I need it to change the url I keep on file. Unfortunately the URL property does not get updated. thanks, Mike On 2/7/06, Francois Piette [EMAIL PROTECTED] wrote: Assuming you use THttpCli, there is a property called FollowRedirection. Set it to true. 1. Did you mean FollowRelocation? 2. Does it automatically then handle the redirection. Or will it trigger the OnLocationChange event where I need to get the new Destination to use? OnLocationChange is always triggered. If ou need to change the relocation the set FollowRelocation to FALSE and run a new request yourself with the url you want to relocate to. -- [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 -- 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
[twsocket] Need help with HTTP
Hello, In the OnDocData of THttpCli descendent, I pause the THTtpCli and Send(Buffer, Len) to the THttpConnection (this is a proxy server). The problem is at ConnectionDataAvailable of THttpConnection, I cannot be sure that all the data is sent or is it complete because sometimes packets are merged and I cannot be sure how much of the downloaded data is actually sent to the client. Here is the code: void __fastcall httpServerClientClass::HTTPClientDocData(TObject *Sender, Pointer Buffer, int Len) { if(compressionType = 0 !absURLTranslation (!noContentLength || transferEncodingChunked)) { HTTPClient-PauseCS(false); sendDataToRequesterClient(Buffer, Len); } else { aggregateDataForGZipSending(Buffer, Len); } } //--- void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer buffer, int len) { if(cacheType == cacheJustAdd) { lockCriticalSection(objectCacheCS); objectCache-Position = cachePosition; objectCache-Write(buffer, len); cachePosition = objectCache-Position; releaseCriticalSection(objectCacheCS); } int Count = 0; if(transferEncodingChunked State == wsConnected lastCommand != httpCommandHEAD protocolStatus[1] != '3') { Count = SendStr(\r\n + String(IntToHex(len, 1)) + \r\n); bytesReceived += Count; } if(State == wsConnected) { Count += Send(buffer, len); DataSent += Count; // count data which is sent by the last buffer if(transferEncodingChunked DataSent = DataToBeSent) { if(protocolStatus[1] != '3' lastCommand != httpCommandHEAD) { SendStr(\r\n0\r\n\r\n); bytesReceived += 7; } } countTransferredPer100ms(Count); setLastActionTime(); } } //--- void __fastcall httpServerClientClass::HTTPClientDocEnd(TObject *Sender) { if(HTTPClient) HTTPClient-setState(httpReady); if(noContentLength || transferEncodingChunked) if(cacheType == cacheJustAdd) cache-setActualFileSize(cacheURL); if(compressionType 0 || absURLTranslation || (noContentLength !transferEncodingChunked)) SendDocumentWGZip(); else { if(transferEncodingChunked) chunkedTransferEnded = true; } } //--- void __fastcall httpServerClientClass::ConnectionDataSentCleartextTunnel(TObject *Sender, WORD Error) { ++bytesSent; if( ( (!transferEncodingChunked DataSent = DataToBeSent DataPrevSent == DataSent) || (transferEncodingChunked chunkedTransferEnded) ) || Error || (lastCommand == httpCommandHEAD || protocolStatus[1] == '3') ) { objectPosition = DataSent; socketError = Error; endOfResponse(); if(!FKeepAlive || Error) Shutdown(1); return; } if(HTTPClient) HTTPClient-ResumeCSIfNotPausedByThrottler(); } The error I get is it sometimes shuts down before all the data is actually pumped. Hope you can help. Best Regards, SZ -- 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] FTP resuming transfers
Its possible that a client can rollback some part of the file incase the end (where the transfer was interrupted) is corrupt. Some clients do a REST to eg. 4kb less than the current size. I think it makes more sense to set the position and size when the transfer begins following a REST command. Dan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francois PIETTE Sent: 31 August 2006 20:34 To: ICS support mailing Subject: Re: [twsocket] FTP resuming transfers Do you mean it could be smaller than his previous size when resuming a transfert ? Yes, that's what I mean and the question :)) If a resumed transfer is smaller than the existing file, then there is a problem ! It is likely that the start of the local file is no more the same as the copy on the server and the whole transfert is corrupted. -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Thursday, August 31, 2006 9:18 PM Subject: Re: [twsocket] FTP resuming transfers Francois PIETTE wrote: I reworked the streams stuff in both FTP C/S today and fixed some bugs, everything was tested sucessfully with 64-bit streams. There's only one question I cannot answer by myself. TFileStream in mode fmOpenWrite does not set its size to current position when it is destroyed. Won't it make sense to set stream size explizitely to the current position in the FtpCli/FtpSrv when data connection is closed (although I guess that it won't work in D2 since method Size exists since D3)? What do you think? Do you mean it could be smaller than his previous size when resuming a transfert ? Yes, that's what I mean and the question :)) I don't think so. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] 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 -- 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