Re: [twsocket] Client close exception and connection doubt

2007-04-18 Thread Francois PIETTE
> This looks like there is no free non-paged memory. I dont know if there
> are TIME_WAIT sockets if no connection to host is possible.

Using NetStat command line utility can show sockets in TIME_WAIT.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be



- Original Message - 
From: "Wilfried Mestdagh" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Saturday, April 14, 2007 6:13 PM
Subject: Re: [twsocket] Client close exception and connection doubt


> Hello Éric,
>
>> The exception that was raised was "Socket operation on non-socket (#10038 
>> in
>
> Possible the socket was already destroyed. Other possibility is that
> somewhere some pointer is pointing wrong or is been overwritten. Very
> difficult to say.
>
>> came to see on the morning the whole windows tcp/ip was inoperant, 
>> Firefox,
>> Internet Explorer was not working and neither the windows network, I
>> coulnd´t even ping any machine on my network.
>
> This looks like there is no free non-paged memory. I dont know if there
> are TIME_WAIT sockets if no connection to host is possible. Never
> checked this. But if you have a connection and you disconnect then
> windows keeps internally the socket alive for a few minutes. So you have
> to be sure to have enough RAM installed. Also other things and
> applications can eventueally use the non-paged pool.
>
> ---
> Rgds, Wilfried [TeamICS]
> http://www.overbyte.be/eng/overbyte/teamics.html
> http://www.mestdagh.biz
>
> -- 
> 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] Client close exception and connection doubt

2007-04-14 Thread Wilfried Mestdagh
Hello Éric,

> The exception that was raised was "Socket operation on non-socket (#10038 in

Possible the socket was already destroyed. Other possibility is that
somewhere some pointer is pointing wrong or is been overwritten. Very
difficult to say.
   
> came to see on the morning the whole windows tcp/ip was inoperant,  Firefox,
> Internet Explorer was not working and neither the windows network, I 
> coulnd´t even ping any machine on my network.

This looks like there is no free non-paged memory. I dont know if there
are TIME_WAIT sockets if no connection to host is possible. Never
checked this. But if you have a connection and you disconnect then
windows keeps internally the socket alive for a few minutes. So you have
to be sure to have enough RAM installed. Also other things and
applications can eventueally use the non-paged pool.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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] Client close exception and connection doubt

2007-04-13 Thread Éric Fleming Bonilha
Hello Wilfried,


> What is exacly the exception message ?

The exception that was raised was "Socket operation on non-socket (#10038 in 
Disconnect (closesocket))."
and it was raised on this:

|00507C4D|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|RaiseException|2009[4]  |
|0050D08B|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|SocketError   |7045[17] |
|0050CFD8|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|SocketError   |7028[0]  |
|0050CBD1|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|InternalClose |6672[34] |
|0050CACF|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|Close |6589[1]  |
|0050939A|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|Destroy   |4303[8]  |
|00509348|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
|Destroy   |4295[0]  |
|0050F4E3|Servidor.exe|OverByteICSWSocket.pas|TCustomLineWSocket 
|Destroy   |8104[11] |

This is the call stack that was created by EurekaLog.

The exception was raised when I was trying to free the TWSocket component, 
see the call stack, first the Destroy of TCustomLineeWSocket is called, and 
see when TCustomWSocket calls the Close routine, it calls the InternalClose 
that raises the exception.

> You have to call Close (or CloseDelayed), and in OnSessionClosed you
> post a message to custom message handler where you connect again.

I will try to do that way, sending a custom message to make a reconnection

> Is it 'no buffer space available' ? Because Windows keep the socket for
> a while after closing the connection (I think 2 minute). Sockets are
> made into the non paged memory pool which stop growing at 1/8 the size
> of physical RAM. So with the amount of sockets in TIME_WAIT state + the
> sockets you create it could be that you run out of memory ? Consider
> that a socket takes around 2 KB, and that overlapped IO (used by
> winsock) eat also in blocks of 4 KB.

Actually I don´t remember very well why it raised this EOutOfMemory 
exception, I will try to reproduce it once again and see where is raises

> Definitively not. But possible you have a memory problem because of the
> TIME_WAIT sockets (nothing to do with ICS, but that's how winsock
> works).

I´m a little affraid of this TIME_WAIT sockets :) As I said on my last 
e-mail, one day I have made one test and I left my software trying to get 
video from 20 different inacessible hosts, I left it by night, and when I 
came to see on the morning the whole windows tcp/ip was inoperant,  Firefox, 
Internet Explorer was not working and neither the windows network, I 
coulnd´t even ping any machine on my network.
Do you know why this could have happened? Considering that mny software was 
doing that reconnect procedure for all hosts.

> Use OnSessionClosed. But do not reconnect from within the event handler,
> but post a custom message so that the reconnect is outside the event.

Thanks I will try to implement on that way, Arno also gave me the same 
advice

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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] Client close exception and connection doubt

2007-04-13 Thread Éric Fleming Bonilha
> You have to call Abort once Connect has been called and OnSessionClosed
> has not been triggered yet to abort the session. Then in OnSessionClosed
> start the timer or post a custom message if you want to reconnect at once.

Ok, now I undestood, I will try to implement on that way

Thank you Arno!

>
> Éric
-- 
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] Client close exception and connection doubt

2007-04-13 Thread Wilfried Mestdagh
Hello Éric,

> Actually I thing that this exception was raised because of the
> architecture of my software and I need an opinion about that.

What is exacly the exception message ?

> when I have some hosts down. My app has a Timeout parameter (Default 4
> seconds) when if it doesn´t receives video from the host it closes the
> connection and opens it again

You have to call Close (or CloseDelayed), and in OnSessionClosed you
post a message to custom message handler where you connect again.

> I have tried to do this reconnect to the host by 2 ways, by Closing
> and Opening the TWSocket connection again and by Destroying and
> Creating a new TWSocket component each time it needs to reconnect to
> the host (at each 4 seconds)

Both are good. Closing / opening will be the most preferabel in my
opinion.

> on the first way (Closing and Opening) I
> got some EOutOfMemory error on ICS

Is it 'no buffer space available' ? Because Windows keep the socket for
a while after closing the connection (I think 2 minute). Sockets are
made into the non paged memory pool which stop growing at 1/8 the size
of physical RAM. So with the amount of sockets in TIME_WAIT state + the
sockets you create it could be that you run out of memory ? Consider
that a socket takes around 2 KB, and that overlapped IO (used by
winsock) eat also in blocks of 4 KB.

> and on this second way (Destroying
> and Creating the TWSocket component) I got that exception message at
> the beggining of the email.

I cannot see the exact exception message. Can you give it ?

> Can you tell me if this reconnection procedure that I made (each 4
> seconds for down hosts) is dangerous to TCP at any way?

Definitively not. But possible you have a memory problem because of the
TIME_WAIT sockets (nothing to do with ICS, but that's how winsock
works).

> Another thing that I have thinked is that if I need to wait the
> TWSocket connection error message before trying to reconnect to the
> host or I can close if before receiving the error message?

Use OnSessionClosed. But do not reconnect from within the event handler,
but post a custom message so that the reconnect is outside the event.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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] Client close exception and connection doubt

2007-04-13 Thread Arno Garrels
Éric Fleming Bonilha wrote:
>> Éric,
> 
>> Since ICS works asynchronous a reconnect-timer should be started from
>> event handler OnSessionClosed, is that the case?
>> Also the best place to destroy the object is from OnSessionClosed as
>> well.
> 
> But the OnSessionClosed event will be triggered if I try to connect
> to an 
> inacessible host?

Yes, after Connect executed without an exception (better wrap Connect
in a try except block) OnSessionConnected as well as OnSessionClosed will
fire, the error passed to OnSessionConnected may be helpfull. 

> 
> I think that my actual reconnect-timer is bugged, because lets
> imagine that 
> I call the connect routine to make a connection, if the host is
> unavailable 
> it will take some time to return me a connection error event right?
> And this 
> time is more than 4 seconds.. but on my actual implementation I wait
> just 4 
> seconds before trying to open the connection again, and I don´t know
> if this 
> can mess with windows TCP implementation

You have to call Abort once Connect has been called and OnSessionClosed
has not been triggered yet to abort the session. Then in OnSessionClosed
start the timer or post a custom message if you want to reconnect at once. 

> 
> Éric
-- 
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] Client close exception and connection doubt

2007-04-13 Thread Éric Fleming Bonilha
> Éric,

> Since ICS works asynchronous a reconnect-timer should be started from
> event handler OnSessionClosed, is that the case?
> Also the best place to destroy the object is from OnSessionClosed as
> well.

But the OnSessionClosed event will be triggered if I try to connect to an 
inacessible host?

I think that my actual reconnect-timer is bugged, because lets imagine that 
I call the connect routine to make a connection, if the host is unavailable 
it will take some time to return me a connection error event right? And this 
time is more than 4 seconds.. but on my actual implementation I wait just 4 
seconds before trying to open the connection again, and I don´t know if this 
can mess with windows TCP implementation

Éric 

-- 
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] Client close exception and connection doubt

2007-04-13 Thread Arno Garrels
Éric,

Since ICS works asynchronous a reconnect-timer should be started from
event handler OnSessionClosed, is that the case? 
Also the best place to destroy the object is from OnSessionClosed as
well.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html 


Éric Fleming Bonilha wrote:
> Hello all,
> 
> I want to discuss an architectural issue here
> I´m debugging an application of mine and yesterday it has stopped
> working and I got the following EurekaLog call stak information 
> 
>> 00507C4D|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |RaiseException|2009[4]  |
>> 0050D08B|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |SocketError   |7045[17] |
>> 0050CFD8|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |SocketError   |7028[0]  |
>> 0050CBD1|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |InternalClose |6672[34] |
>> 0050CACF|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |Close |6589[1]  |
>> 0050939A|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |Destroy   |4303[8]  |
>> 00509348|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |Destroy   |4295[0]  |
>> 0050F4E3|Servidor.exe|OverByteICSWSocket.pas   
>> |TCustomLineWSocket   |Destroy  
>> |8104[11] | 7C91503E|ntdll.dll   |  |   
>> |bsearch   | | 7E36A03E|USER32.dll 
>> |  |
>> |ClientThreadSetup | | 7C90EAF5|ntdll.dll  
>> |  |
>> |KiUserApcDispatcher   | | 7E369239|USER32.dll 
>> |  |
>> |CharUpperBuffW| | 7E36AEBF|USER32.dll 
>> |  |
>> |CharUpperBuffA| | 7E36AEE3|USER32.dll 
>> |  |
>> |CharUpperBuffA| | 7C90E21D|ntdll.dll  
>> |  |
>> |ZwQueryVirtualMemory  | |
>> 7C80B9B7|kernel32.dll|  |   
>> |VirtualQueryEx| |
>> 7C80B9A0|kernel32.dll|  |   
>> |VirtualQueryEx| |
>> 7C80B9E1|kernel32.dll|  |   
>> |VirtualQuery  | |
>> 7C80B9D1|kernel32.dll|  |   
>> |VirtualQuery  | |
>> 00509286|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |Create|427
1[6]  |
>> 00509230|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket 
>> |Create|4265[0]  |
>> 0050DEC6|Servidor.exe|OverByteICSWSocket.pas   
>> |TCustomSocksWSocket  |Create   
>> |7254[1]  | 0050DEB0|Servidor.exe|OverByteICSWSocket.pas   
>> |TCustomSocksWSocket  |Create   
>> |7253[0]  | 0050F45E|Servidor.exe|OverByteICSWSocket.pas   
>> |TCustomLineWSocket   |Create   
>> |8084[1]  | 0050F448|Servidor.exe|OverByteICSWSocket.pas   
>> |TCustomLineWSocket   |Create   
>> |8083[0]  | 00534F14|Servidor.exe|UTDriverCommSocketThread.pas 
>> |TDriverCommSocketThread  |Execute  
>> |355[11]  | 7C90E57A|ntdll.dll   |  |   
>> |NtSetEvent| |
>> 7C80A021|kernel32.dll|  |   
>> |SetEvent  | |
>> 7C80A017|kernel32.dll|  |   
>> |SetEvent  | |  
> 
> 
> I have seen on OverByteICSWSocket.pas InternalClose on line 6672 it
> raises that exception only when ICS is used on DLL, but that is not
> my case  
> 
> Actually I thing that this exception was raised because of the
> architecture of my software and I need an opinion about that. 
> My software is a service application that can have several TWSocket
> clients to get live video data from different sources. Each instance
> of TWSocket is working on a different thread.  
> Apparently my application doesn´t work very well when some hosts are
> down, it frequently shuts the service down, but this happens only
> when I have some hosts down. My app has a Timeout parameter (Default
> 4 seconds) when if it doesn´t receives video from the host it closes
> the connection and opens it ag

[twsocket] Client close exception and connection doubt

2007-04-13 Thread Éric Fleming Bonilha
Hello all,

I want to discuss an architectural issue here
I´m debugging an application of mine and yesterday it has stopped working and I 
got the following EurekaLog call stak information

|00507C4D|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |RaiseException|2009[4]  |
|0050D08B|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |SocketError   |7045[17] |
|0050CFD8|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |SocketError   |7028[0]  |
|0050CBD1|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |InternalClose |6672[34] |
|0050CACF|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |Close |6589[1]  |
|0050939A|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |Destroy   |4303[8]  |
|00509348|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |Destroy   |4295[0]  |
|0050F4E3|Servidor.exe|OverByteICSWSocket.pas|TCustomLineWSocket
   |Destroy   |8104[11] |
|7C91503E|ntdll.dll   |  |  
   |bsearch   | |
|7E36A03E|USER32.dll  |  |  
   |ClientThreadSetup | |
|7C90EAF5|ntdll.dll   |  |  
   |KiUserApcDispatcher   | |
|7E369239|USER32.dll  |  |  
   |CharUpperBuffW| |
|7E36AEBF|USER32.dll  |  |  
   |CharUpperBuffA| |
|7E36AEE3|USER32.dll  |  |  
   |CharUpperBuffA| |
|7C90E21D|ntdll.dll   |  |  
   |ZwQueryVirtualMemory  | |
|7C80B9B7|kernel32.dll|  |  
   |VirtualQueryEx| |
|7C80B9A0|kernel32.dll|  |  
   |VirtualQueryEx| |
|7C80B9E1|kernel32.dll|  |  
   |VirtualQuery  | |
|7C80B9D1|kernel32.dll|  |  
   |VirtualQuery  | |
|00509286|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |Create|4271[6]  |
|00509230|Servidor.exe|OverByteICSWSocket.pas|TCustomWSocket
   |Create|4265[0]  |
|0050DEC6|Servidor.exe|OverByteICSWSocket.pas|TCustomSocksWSocket   
   |Create|7254[1]  |
|0050DEB0|Servidor.exe|OverByteICSWSocket.pas|TCustomSocksWSocket   
   |Create|7253[0]  |
|0050F45E|Servidor.exe|OverByteICSWSocket.pas|TCustomLineWSocket
   |Create|8084[1]  |
|0050F448|Servidor.exe|OverByteICSWSocket.pas|TCustomLineWSocket
   |Create|8083[0]  |
|00534F14|Servidor.exe|UTDriverCommSocketThread.pas  |TDriverCommSocketThread   
   |Execute   |355[11]  |
|7C90E57A|ntdll.dll   |  |  
   |NtSetEvent| |
|7C80A021|kernel32.dll|  |  
   |SetEvent  | |
|7C80A017|kernel32.dll|  |  
   |SetEvent  | |


I have seen on OverByteICSWSocket.pas InternalClose on line 6672 it raises that 
exception only when ICS is used on DLL, but that is not my case

Actually I thing that this exception was raised because of the architecture of 
my software and I need an opinion about that.
My software is a service application that can have several TWSocket clients to 
get live video data from different sources. Each instance of TWSocket is 
working on a different thread. 
Apparently my application doesn´t work very well when some hosts are down, it 
frequently shuts the service down, but this happens only when I have some hosts 
down. My app has a Timeout parameter (Default 4 seconds) when if it doesn´t 
receives video from the host it closes the connection and opens it again, I 
think that I´m having some problems on this timeout concept, so, for example if 
I have 5 down hosts, at each 4 seconds my app will try to connect to this host, 
and I don´t know why, it is compromising my app stability
I have tried to