Re: [twsocket] TWsocket and EStackOverflow
This is where things like Eureka Log come in very handy. (or various other Exception Handlers) Matt -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of RTT Sent: Thursday, October 25, 2012 12:14 PM To: ICS support mailing Subject: Re: [twsocket] TWsocket and EStackOverflow On 22-10-2012 19:04, LeNif wrote: > My problem is when I disconnect the socket and I immediately > reconnects, I get an error EStackOverflow And if the reconnect is not "immediately" (you wait more time), the error does not occur? Have you checked the stack trace, in that stack overflow condition, to see what code is being called, most probably recursively? -- 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
On 22-10-2012 19:04, LeNif wrote: My problem is when I disconnect the socket and I immediately reconnects, I get an error EStackOverflow And if the reconnect is not "immediately" (you wait more time), the error does not occur? Have you checked the stack trace, in that stack overflow condition, to see what code is being called, most probably recursively? -- 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
> I already try, after reading the Wiki, the Shutdown(1) procedure, anyway, the > result is the same. I try close, shutdown, abort ... etc. Make a stripped down version of your application and mail it to me. Be sure to include a complete project with only the code required to reproduce the error. Remove everything else (no exe of course). I won't look at it if I doesn't compile immediately! -- 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 -- 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
LeNif wrote: > I already try, after reading the Wiki, the Shutdown(1) procedure, > anyway, the result is the same. I try close, shutdown, abort ... etc. Try the following: >From the OnSessionClosed event handler post a custom window message and reconnect when that message is handled. -- Arno -- 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. Di
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://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 set
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
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
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
Re: [twsocket] TWsocket and EStackOverflow
> My problem is when I disconnect the socket and I immediately reconnects, I get an error EStackOverflow > I can not find the cause of this error. TWSocket is asynchronous. You must not reconnect before actual disconnection is done. Use OnSessionClosed event to know when disconnection is complete. -- 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