一.使用.Net 2.0提供的Ping命令
1
AutoResetEvent waiter
=
new
AutoResetEvent(
false
);
2
Ping myPing
=
new
Ping();
3
myPing.PingCompleted
+=
new
PingCompletedEventHandler(myPing_PingCompleted);
4
string
data
=
"
OK
"
;
//
Ping 发送的数据
5
byte
[] buffer
=
Encoding.ASCII.GetBytes(data);
6
int
timeout
=
10000
;
7
PingOptions options
=
new
PingOptions(
64
,
true
);
8
myPing.SendAsync(_AppState.ServerName, timeout, buffer, options, waiter);

2

3

4

5

6

7

8

二.使用本地tcp集合,此集合由操作系统层面提供,也是.Net2.0支持的












