Article View: borland.public.cppbuilder.internet.socket
Article #1359Re: socket issue
From: mat
Date: Mon, 12 Feb 2007 06:03
Date: Mon, 12 Feb 2007 06:03
56 lines
2948 bytes
2948 bytes
if i try to ping the pc before connecting will it be a good idea? i put an IdIcmpClient component i write simple: AnsiString buffer; unsigned short a; IdIcmpClient1->Ping(buffer,a); Application->ProcessMessages(); and in its onreply even i have Memo1->Lines->Add(AnsiString(AReplyStatus.MsRoundTripTime) +" from "+AReplyStatus.FromIpAddress); i noticed that if i try ping an ip that possible doesnt exist i get a 1000+ from 0.0.0.0 or if i write a url that doesnt exist i get an exception in the timeout that i have declared. is this a good (i mean programming way good) way to understand if an ip exists before making the socketconnection->connected=true? thks "mat" <mat@hotmail.com> wrote in message news:45cbd7c8$1@newsgroups.borland.com... > hello,im using a socketconnection component to connect to a > datasnap server.i do socketconnection->connected=true; the code is in a > separate thread and i have some application->processmessages in order to > get some visual > feedback (e.g. a messagebox before it starts connected and a messagebox if > it connects). > the code is of course in a try catch . > > the issue is the following: > when i try to connect to an existing pc it does what its supposed to do > almost immediately, > if the datasnap server is up it connects ,if its not up (e.g. if im not > running the scktsrv.exe)it throws an exception. > > when i try to connect to an not existing pc (wrong ip) the system freezes > and waits for a rather > big timeout. > > if i try to connect to a firewalled pc (which blocks such incomming) it > freezes again and waits for > a rather big timeout again. > > is this something i can fix?the waiting timeout is very big,and the > program freezes (although its in its own > thread). > > i thought of first pinging the remote pc to see if its up and then try to > connect to it but that would introduce > another waiting time(the ping waiting time) > what do people usually do to deal with this kind of problems? > > thks >
Technical Details
Message-ID:
<45d00321@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!homer!news.glorb.com!news-spur1.glorb.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45cbd7c8$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,54a50302c070b08c X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "mat" <mat@hotmail.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <45cbd7c8$1@newsgroups.borland.com> Subject: Re: socket issue Date: Mon, 12 Feb 2007 06:03:22 -0000 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 131.227.231.116 Message-ID: <45d00321@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1171260193 131.227.231.116 (11 Feb 2007 22:03:13 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!homer!news.glorb.com!news-spur1.glorb.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail