D.Tkalcec (RTC)
|
|
« Reply #1 on: September 09, 2014, 08:43:41 AM » |
|
When using a connection-based API like WinSock, the OnConnect event is called when a connection has just been established. But when using the WinInet or WinHTTP API (set useProxy=True or useWinHTTP=True) on Windows, which do not have a concept of opening or closing physical connections (it has a concept of requests instead), the OnConnect event is called every time the low-level API objects have been initialized for use, to emulate the behavior of connection-based APIs, even though no physical connection is being established at that time. Because WinInet and WinHTTP APIs do not have a concept of physical connections, if you want your code to work with all supported APIs, you should set the AutoConnect and ReconnectOn properties of the TRtcHttpClient component to TRUE and only worry about requests and responses, but not about physical connections.
Based on your statement, I can only assume that you were using the WinInet or WinHTTP APIs (the useProxy or the useWinHTTP property was set to TRUE), or that the Server you were testing the code with has been closing the connection. Some Servers will close a connection immediately after sending a response, while other Servers have time-out periods to close idle connections. If a Server closes its side of a connection, there is nothing a Client can do about it, except opening a new connection before sending a new request.
In short, I can not recommend writing code which relies on the connection-specific events. These events may be useful for statistical purposes, but they are not a reliable way of knowing when a physical connection is really being open or closed, unless you are using a connection-based API like WinSock.
Best Regards, Danijel Tkalcec
|