Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TClientSocket error 10061

150 views
Skip to first unread message

Graham Powell

unread,
Nov 28, 2005, 1:04:17 PM11/28/05
to
If I have a TClientSocket and try to Open a connection to an IP address
where there is no listening Server socket, I get a 10061 error as expected.
But in the ClientSocket Error event I set Error := 0 before exiting and I
still get an application error.
The documentation states that if you set Error to 0, the error is considered
dealt with. Looking at the source code of ScktComp.pas this would appear to
be the case, but not in practice.

So, is the ScktComp.dcu actually compiled from the ScktComp.pas in the
source directory?

I have found that if I copy ScktComp.pas to my working directory, change the
name to ScktCompX.pas, change the unit name to ScktCompX. Then set my uses
clause to ScktCompX. Now if I recompile, I get ScktComp re-appear in my uses
clause, but it now works. Connecting to a non existing server does not
generate an application error.

This happens with Delphi 7 and Delphi 2005.

Any clues as to what is going on?

Graham


Remy Lebeau (TeamB)

unread,
Nov 28, 2005, 2:00:19 PM11/28/05
to

"Graham Powell" <gra...@deephaven.co.uk> wrote in message
news:438b467b$1...@newsgroups.borland.com...

> I have found that if I copy ScktComp.pas to my working directory,
> change the name to ScktCompX.pas, change the unit name to
> ScktCompX. Then set my uses clause to ScktCompX.

You do not need to do that. You can, and should, leave the original name
as-is. That way, the file actually overrides the VCL. Otherwise, you have
two units sitting side-by-side, which is not very useful.


Gambit


Graham Powell

unread,
Nov 29, 2005, 5:09:57 AM11/29/05
to
I did originally try what you suggested but failed to force Delphi to use
the .pas rather than the existing .dcu

Now I can trace the problem and it is becoming more mysterious.

Below is a section of code from ScktComp.pas
After the 10061 error is detected, we finally arrive here and call the Event
in the main application where the ErrorCode is set to 0. The application
error occurs upon execution of the END statement as indicated.

procedure TCustomSocket.Error(Socket: TCustomWinSocket; ErrorEvent:
TErrorEvent;
var ErrorCode: Integer);
begin
if Assigned(FOnError) then
FOnError(Self, Socket, ErrorEvent, ErrorCode);
end; //Application error occurs here

If I remove all the code from my event, the problem is still remains.
If I de-assign the event, all is fine as it skips past the FOnError call.
For debugging purposes I changed the above routine to the following:

procedure TCustomSocket.Error(Socket: TCustomWinSocket; ErrorEvent:
TErrorEvent;
var ErrorCode: Integer);
begin
if Assigned(FOnError) then
ClearTheWinsockError(ErrorCode);
end;

This works - no application error

I know that this is not a problem with the Client Socket component as I have
created a test application to do the same thing and there is no problem.
So somehow I am managing to corrupt something which causes the error.

Any clues much appreciated.
Graham


"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:438b...@newsgroups.borland.com...

Graham Powell

unread,
Nov 29, 2005, 9:27:54 AM11/29/05
to
The problem has been fixed. The form on which the Client Socket was placed
had the remnants of another 3rd party internet component in the Uses clause
which was no longer used.

For some reason this caused TClientSocket to give an application error if a
connection failed.


"Graham Powell" <gra...@deephaven.co.uk> wrote in message

news:438c...@newsgroups.borland.com...

Remy Lebeau (TeamB)

unread,
Nov 29, 2005, 2:26:52 PM11/29/05
to

"Graham Powell" <gra...@deephaven.co.uk> wrote in message
news:438c...@newsgroups.borland.com...

> I did originally try what you suggested but failed to force
> Delphi to use the .pas rather than the existing .dcu

Did you disable the use of runtime packages? Delphi is specifically
designed to allow users to override the DCUs by including PAS files directly
into the project that use the same symbols as the DCUs. But it only works
if you do not use runtime packages.


Gambit


Graham Powell

unread,
Nov 30, 2005, 3:14:49 AM11/30/05
to
I did manage to get Delphi to use the .pas file I had copied to my directory
and traced what happened when the error occurred. The easy way was to put my
directory first in the library path.

The problem turned out to be the following: If you have an IPWorks FTP
component on the same form as a Delphi TClientSocket and now you attempt to
make a connection from the TClientSocket to a non-existent server, an
application error will occur during the processing of the 10061 error.
If you remove the FTP component and all references to it in the uses clause,
the problem goes away.

Graham

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message

news:438cab68$1...@newsgroups.borland.com...

0 new messages