test network presence

  • Thread starter Thread starter Miliuccio
  • Start date Start date
M

Miliuccio

how can i test the presence of a server on the network before to try an sql
comunication?

in vb programming like
ping for example
 
You could check if the device has been assigned an ip address, assuming
you are not using fixed ip addressess.

Chris
 
That's going to depend on the characteristics of the server. Can you PING
it? If so, you might try doing that before trying to connect with SQL (I'm
sure there's been code for PING posted here before). Why don't you want to
just make your SQL connection, rather than using multiple steps to decide
whether to go ahead or not?

Paul T.
 
Try this...

public static bool IsWebAccessible()
{
bool retVal = false;

try
{
string hostName = System.Net.Dns.GetHostName();

System.Net.IPHostEntry ipheThisHost =
System.Net.Dns.GetHostByName(hostName);
System.Net.IPAddress ipThisAddr = ipheThisHost.AddressList[0];

string ip = ipThisAddr.ToString();
string localhost =
System.Net.IPAddress.Parse("127.0.0.1").ToString();

retVal = (ip!=localhost);
}
catch(Exception)
{
retVal = false;
}

return retVal;
}

Cheers

Chris
 
That seems like a *very* bad design choice. Why don't you look at
OpenNETCF's AdapterStatusMonitor class. That should keep you updated about
when network connections to your device come and go. If it's the server
that's coming and going, I'd be very reluctant to chew up the network
bandwidth, processor cycles, etc. to check for presence every couple of
seconds.

Paul T.

Miliuccio said:
i want to do it in a timer.
try a connection every 5 seconds stop my job.

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
ha
scritto nel messaggio news:u%[email protected]...
That's going to depend on the characteristics of the server. Can you
PING
it? If so, you might try doing that before trying to connect with SQL (I'm
sure there's been code for PING posted here before). Why don't you want to
just make your SQL connection, rather than using multiple steps to decide
whether to go ahead or not?

Paul T.
 
i am trying
have you got an example to retrive information on Activesync connection?


Paul G. Tobey said:
That seems like a *very* bad design choice. Why don't you look at
OpenNETCF's AdapterStatusMonitor class. That should keep you updated about
when network connections to your device come and go. If it's the server
that's coming and going, I'd be very reluctant to chew up the network
bandwidth, processor cycles, etc. to check for presence every couple of
seconds.

Paul T.

Miliuccio said:
i want to do it in a timer.
try a connection every 5 seconds stop my job.

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
ha
scritto nel messaggio news:u%[email protected]...
That's going to depend on the characteristics of the server. Can you
PING
it? If so, you might try doing that before trying to connect with SQL (I'm
sure there's been code for PING posted here before). Why don't you
want
to
just make your SQL connection, rather than using multiple steps to decide
whether to go ahead or not?

Paul T.

how can i test the presence of a server on the network before to try an
sql
comunication?

in vb programming like
ping for example
 
The SQL Server connection doesn't care what sort of network connection you
have. *Any* example that shows how to get the data will be the same whether
the connection is made over ActiveSync or a real network card, or via a
dial-up connection.

Paul T.

Miliuccio said:
i am trying
have you got an example to retrive information on Activesync connection?


"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
ha
scritto nel messaggio news:[email protected]...
That seems like a *very* bad design choice. Why don't you look at
OpenNETCF's AdapterStatusMonitor class. That should keep you updated about
when network connections to your device come and go. If it's the server
that's coming and going, I'd be very reluctant to chew up the network
bandwidth, processor cycles, etc. to check for presence every couple of
seconds.

Paul T.

Miliuccio said:
i want to do it in a timer.
try a connection every 5 seconds stop my job.

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
ha
scritto nel messaggio That's going to depend on the characteristics of the server. Can you
PING
it? If so, you might try doing that before trying to connect with SQL
(I'm
sure there's been code for PING posted here before). Why don't you want
to
just make your SQL connection, rather than using multiple steps to decide
whether to go ahead or not?

Paul T.

how can i test the presence of a server on the network before to try an
sql
comunication?

in vb programming like
ping for example
 
Can i do it without hostname

i must do it for different palm, with different names.
Or i can first resolve myhostname?and then check it IPnumber.

i try this code with mypalm hostname and it work correctly (when i put palm
in is case it change the IP number so i can intercept the connection to the
network.
 
Back
Top