[twsocket] HttpCli.Get problem
Hi all, I use ICS for my application, I use Get method to get an url 2 problems: 1/ I need to get an url, when I launch .get method, the first time I get a result, the second time I use .get method, it doesn't respond, like responding from cache. strange. Hope you can understand 2/ I put this code: try Data := TMemoryStream.Create; HttpCli.URL := MyURL; HttpCli.RcvdStream := Data; HttpCli.Get; Do something with result ... ; finally Data.Free; end; If the url doesn't exist, I get an exception but source in Finally clause is never fired ... How to make it running trough the Finally when the url don't exist ? Regards Lenif, -- 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] TWsocket and EStackOverflow
Hello, When I use Wireshark to snif communication, I see that exchange with the device continue, even after the close that's really strange ... Maybe the problem is with the device and not with my socket ... thanks LeNif From: François Piette Date: 2012-10-24 20:14 To: 'ICS support mailing' Subject: Re: [twsocket] TWsocket and EStackOverflow I don't see anything obviously wrong there. Just to be sure, please test one of the sample programs (For example OverbyteIcsClient7.dproj which is close to your own test) delivered with ICS to see if they works OK. If not, then you have somehow corrupted your ICS installation. -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -Message d'origine- De : twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] De la part de LeNif Envoyé : mercredi 24 octobre 2012 07:55 À : twsocket Objet : Re: [twsocket] TWsocket and EStackOverflow Hello, When I say wait, it 's because, I look at my debug memo and I don't click on connect before the event OnsessionClosed is fired, I manually wait with my eyes ! ;) Idon't use the wait() procedure ! I make a copy paste of my source code, as you can see, it's really simple: (I just suppress each event code where there is just a debug lines added to the memo to see if event is fired) procedure TForm1.Button2Click(Sender: TObject); begin // start or stop if TCPCLient.State = wsClosed then TCPClient.Connect else TCPClient.close; end; procedure TForm1.Button3Click(Sender: TObject); begin TCPClient.SendStr(CHR($21)); end; procedure TForm1.Button4Click(Sender: TObject); begin TCPClient.SendStr(CHR($55)); end; procedure TForm1.dvLed1Change(Sender: TObject); begin // event fired by a led displaying connection status If dvLed1.LedOn then Button2.Caption := 'Disconnect' else Button2.Caption := 'Connect' end; procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin TCPClient.Close; end; Procedure TForm1.LogIt(AMessage: string); begin meLog.Lines.Add(Amessage); end; procedure TForm1.TCPClientDataAvailable(Sender: TObject; ErrCode: Word); var Buffer, hexBuf : array [0..1023] of char; Len: Integer; Src: TSockAddrIn; SrcLen : Integer; hexstr: String; begin LogIt('DataAvalaible: Error='+IntToStr(ErrCode)); SrcLen := SizeOf(Src); Len:= TCPClient.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); if Len = 0 then begin LogIt('Data from '+StrPas(inet_ntoa(Src.sin_addr))+' - data : ' + (strpas(Buffer))); end; end; procedure TForm1.TCPClientSessionClosed(Sender: TObject; ErrCode: Word); begin logIt('SessionClosed: Error='+IntToStr(ErrCode)); dvLed1.LedOn := False; end; procedure TForm1.TCPClientSessionConnected(Sender: TObject; ErrCode: Word); begin logIt('SessionConnected: Error='+IntToStr(ErrCode)); dvLed1.LedOn := True; end; LeNif From: François Piette Date: 2012-10-23 18:39 To: 'ICS support mailing' Subject: Re: [twsocket] TWsocket and EStackOverflow Hello, thanks but I already wait for OnsessionClosed befor restarting. Wait ? Does this means you don't use the events ? I post a capture with log info here ... http://imageshack.us/photo/my-images/844/screenshot47a.png/ Not very interesting... If you have a stack overflow, you probably have a function calling itself recursively. Your wait is probably the culprit but in fact, I don't know because I have no idea about your code. Did you have a look at the sample programs ? -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -- 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 -- 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 -- 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 -- 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
Re: [twsocket] TWsocket and EStackOverflow
Hello Francois, I already try, after reading the Wiki, the Shutdown(1) procedure, anyway, the result is the same. I try close, shutdown, abort ... etc. Every time, the sessionclosed is fired and when I reconnect I get EStackOverflow ! If I close the apps and restart, the connect is working. Maybe I must use a runtime created socket to solve this behaviour ? Thanks F. LeNif From: François Piette Date: 2012-10-24 21:22 To: 'ICS support mailing' Subject: Re: [twsocket] TWsocket and EStackOverflow You should try using Shutdown instead of closing your end. Shutdown ask the other party to close the connection and you receive the sessionclosed event when he accept. If you don't receive sessionclosed event, then you may call Abort. Shutdown is a graceful close (one partu ask the other to break the connection), Abort is an immediate termination of the connection whatever the other party want. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -Message d'origine- De : twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] De la part de LeNif Envoyé : mercredi 24 octobre 2012 20:29 À : twsocket Objet : Re: [twsocket] TWsocket and EStackOverflow Hello, When I use Wireshark to snif communication, I see that exchange with the device continue, even after the close that's really strange ... Maybe the problem is with the device and not with my socket ... thanks LeNif From: François Piette Date: 2012-10-24 20:14 To: 'ICS support mailing' Subject: Re: [twsocket] TWsocket and EStackOverflow I don't see anything obviously wrong there. Just to be sure, please test one of the sample programs (For example OverbyteIcsClient7.dproj which is close to your own test) delivered with ICS to see if they works OK. If not, then you have somehow corrupted your ICS installation. -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -Message d'origine- De : twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] De la part de LeNif Envoyé : mercredi 24 octobre 2012 07:55 À : twsocket Objet : Re: [twsocket] TWsocket and EStackOverflow Hello, When I say wait, it 's because, I look at my debug memo and I don't click on connect before the event OnsessionClosed is fired, I manually wait with my eyes ! ;) Idon't use the wait() procedure ! I make a copy paste of my source code, as you can see, it's really simple: (I just suppress each event code where there is just a debug lines added to the memo to see if event is fired) procedure TForm1.Button2Click(Sender: TObject); begin // start or stop if TCPCLient.State = wsClosed then TCPClient.Connect else TCPClient.close; end; procedure TForm1.Button3Click(Sender: TObject); begin TCPClient.SendStr(CHR($21)); end; procedure TForm1.Button4Click(Sender: TObject); begin TCPClient.SendStr(CHR($55)); end; procedure TForm1.dvLed1Change(Sender: TObject); begin // event fired by a led displaying connection status If dvLed1.LedOn then Button2.Caption := 'Disconnect' else Button2.Caption := 'Connect' end; procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin TCPClient.Close; end; Procedure TForm1.LogIt(AMessage: string); begin meLog.Lines.Add(Amessage); end; procedure TForm1.TCPClientDataAvailable(Sender: TObject; ErrCode: Word); var Buffer, hexBuf : array [0..1023] of char; Len: Integer; Src: TSockAddrIn; SrcLen : Integer; hexstr: String; begin LogIt('DataAvalaible: Error='+IntToStr(ErrCode)); SrcLen := SizeOf(Src); Len:= TCPClient.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); if Len = 0 then begin LogIt('Data from '+StrPas(inet_ntoa(Src.sin_addr))+' - data : ' + (strpas(Buffer))); end; end; procedure TForm1.TCPClientSessionClosed(Sender: TObject; ErrCode: Word); begin logIt('SessionClosed: Error='+IntToStr(ErrCode)); dvLed1.LedOn := False; end; procedure TForm1.TCPClientSessionConnected(Sender: TObject; ErrCode: Word); begin logIt('SessionConnected: Error='+IntToStr(ErrCode)); dvLed1.LedOn := True; end; LeNif From: François Piette Date: 2012-10-23 18:39 To: 'ICS support mailing' Subject: Re: [twsocket] TWsocket and EStackOverflow Hello, thanks but I already wait for OnsessionClosed befor restarting. Wait ? Does this means you don't use the events ? I post a capture with log info here ... http://imageshack.us/photo/my-images/844/screenshot47a.png/ Not very interesting... If you have a stack overflow, you probably have a function calling itself recursively. Your wait is probably the culprit but in fact, I don't know because I have no idea about your code. Did you have a look at the sample programs ? -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http