| View previous topic :: View next topic |
| Author |
Message |
Júlio Cesar Guest
|
Posted: Fri Feb 17, 2006 8:03 pm Post subject: Socket Error 10054 |
|
|
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
|
Posted: Sat Feb 18, 2006 12:03 am Post subject: Re: Socket Error 10054 |
|
|
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
|
Posted: Sat Feb 18, 2006 5:03 am Post subject: Re: Socket Error 10054 |
|
|
"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
|
Posted: Mon Feb 20, 2006 6:03 pm Post subject: Re: Socket Error 10054 |
|
|
It worked
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 |
|
 |
|