BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Socket Error 10054

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Júlio Cesar
Guest





PostPosted: Fri Feb 17, 2006 8:03 pm    Post subject: Socket Error 10054 Reply with quote



Hello,

I have a function that checks if an application is on-line using IdTcpclient
version 10.0.0.76
The code that follows:

**************************************************************
function TForm1.fncTestNetwork(const sHost: string; const wrPort: word;
const wrTimeout: word): boolean;
var
IdTCP: TIdTCPClient;
begin
IdTCP:= TIdTCPClient.Create(nil);
IdTCP.Host:= sHost;
IdTCP.Port:= wrPort;
try
idTCP.ConnectTimeout:= wrTimeout * 1000;
IdTCP.Connect;
if IdTCP.Connected then IdTCP.Disconnect;
Result:= True;
except
on E: Exception do
begin
Result:= False;
end;
end;
IdTCP.Disconnect;
IdTCP.Free;
end;
**************************************************************

And I don't care about the error, I just want to know if it's on-line or
off-line.
But sometimes I receive a messagebox on the screen like:

Socket error # 10054
Connection reset by peer.

The problem is that this messagebox stops my application.
Is it an Indy trick?

How can I solve that?

Thanks in advance!
Back to top
Ciaran Costelloe
Guest





PostPosted: Sat Feb 18, 2006 12:03 am    Post subject: Re: Socket Error 10054 Reply with quote



Jzlio Cesar wrote:

Quote:
And I don't care about the error, I just want to know if it's on-line
or off-line.
But sometimes I receive a messagebox on the screen like:

Socket error # 10054
Connection reset by peer.

If you are running the application in the IDE, by default the exception
will be shown by the IDE before your application catches it, so it may
not be a problem at all.

Ciaran
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 18, 2006 5:03 am    Post subject: Re: Socket Error 10054 Reply with quote



"Júlio Cesar" <neo_x (AT) ig (DOT) com.br> wrote in message
news:43f6246d$1 (AT) newsgroups (DOT) borland.com...

Quote:
The code that follows:

Try this code instead:

function TForm1.fncTestNetwork(const sHost: string; const wrPort: word;
const wrTimeout: word): boolean;
begin
try
with TIdTCPClient.Create(nil) do
try
Host := sHost;
Port := wrPort;
ConnectTimeout := wrTimeout * 1000;
Connect;
finally
Free;
end;
Result := True;
except
Result := False;
end;
end;


Gambit
Back to top
Júlio Cesar
Guest





PostPosted: Mon Feb 20, 2006 6:03 pm    Post subject: Re: Socket Error 10054 Reply with quote

It worked Smile
Thanks!!!

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> escreveu na mensagem
news:43f6a028$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Júlio Cesar" <neo_x (AT) ig (DOT) com.br> wrote in message
news:43f6246d$1 (AT) newsgroups (DOT) borland.com...

The code that follows:

Try this code instead:

function TForm1.fncTestNetwork(const sHost: string; const wrPort:
word;
const wrTimeout: word): boolean;
begin
try
with TIdTCPClient.Create(nil) do
try
Host := sHost;
Port := wrPort;
ConnectTimeout := wrTimeout * 1000;
Connect;
finally
Free;
end;
Result := True;
except
Result := False;
end;
end;


Gambit

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.