H
Heineken
Hi,
I have a problem with the clientsocket component in Borland C++
Builder v6.0 - don't know if this is the correct forum. :-S
The clientsocket component is used to connect to a serversocket
component on another PC within my network - it all works fine, as long
as the PC running the serversocket program is running. If I turn the
PC off, the IP address is no longer available, and because I have the
clientsocket connected to a timer, when the connection is lost, the
client tries to connect to the server IP address over and over again.
Whenever the clientsocket then throws an onerror event, I do the
following:
void __fastcall TSyslogForm::ClientSocket1Error(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int
&ErrorCode)
{
ErrorCode = 0; //error is being handled
Socket->Close();
ClientSocket1->Close();
Timer2->Interval = 5000; // 5 sec delay before reconnecting
Timer2->Enabled = TRUE;
}
However - when the serversocket PC is turned off, the clientsocket
reconnecting over and over again, results in a memory leak where
Windows handles increases until I get an exception like "Windows
socket error: An invalid argument was supplied (10022), on API
'WSACancelASyncRequest'", or "Windows socket error [10055] on API
connect".
I haven't been able to find any solution for this problem. The handles
are handled fine, if the serversocket PC is turned on, but without the
serversocket running. Therefore the problem only seems to exists, when
the IP address is unavailable.
Hope to get some help, and thanx in advance!
- Heine.
I have a problem with the clientsocket component in Borland C++
Builder v6.0 - don't know if this is the correct forum. :-S
The clientsocket component is used to connect to a serversocket
component on another PC within my network - it all works fine, as long
as the PC running the serversocket program is running. If I turn the
PC off, the IP address is no longer available, and because I have the
clientsocket connected to a timer, when the connection is lost, the
client tries to connect to the server IP address over and over again.
Whenever the clientsocket then throws an onerror event, I do the
following:
void __fastcall TSyslogForm::ClientSocket1Error(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int
&ErrorCode)
{
ErrorCode = 0; //error is being handled
Socket->Close();
ClientSocket1->Close();
Timer2->Interval = 5000; // 5 sec delay before reconnecting
Timer2->Enabled = TRUE;
}
However - when the serversocket PC is turned off, the clientsocket
reconnecting over and over again, results in a memory leak where
Windows handles increases until I get an exception like "Windows
socket error: An invalid argument was supplied (10022), on API
'WSACancelASyncRequest'", or "Windows socket error [10055] on API
connect".
I haven't been able to find any solution for this problem. The handles
are handled fine, if the serversocket PC is turned on, but without the
serversocket running. Therefore the problem only seems to exists, when
the IP address is unavailable.
Hope to get some help, and thanx in advance!
- Heine.