Ping 클래스는 2.0에서 추가된 놈이죠.
그래서 1.1에서는 만들어야 되는데..
Ping 관련 모듈 코드프로젝트에서인가 몇년전에 봤습니다. 그거 사용하셔도 되고..
그냥 꽁수 하나 알려드리죠. 도스 명령어 ping으로 하는겁니다.
Public Shared Function ExecuteDosCommand(ByVal pCommand As String) As String
Dim arr As String() = pCommand.Split(New Char() { " "c })
Dim pInfo As New ProcessStartInfo(arr(0))
pInfo.Arguments = pCommand.Replace(arr(0), "")
pInfo.UseShellExecute = False
pInfo.RedirectStandardInput = False
pInfo.RedirectStandardOutput = True
pInfo.RedirectStandardError = True
pInfo.CreateNoWindow = True
Dim process As New Process
process.StartInfo = pInfo
process.Start
Return process.StandardOutput.ReadToEnd
End Function
Public Shared Function Ping(ByVal pIp As String, ByVal pTimeOut As Integer) As Boolean Try
If (Form1.ExecuteDosCommand(("ping -n 1 -w " & pTimeOut.ToString & " " & pIp)).IndexOf(("Reply from " & pIp)) <> -1) Then
Return True
End If
Catch obj1 As Object
End Try
Return False
End Function
실행~~~
Console.WriteLine(Ping("127.0.0.1", 3000));
>> 리플렉터에서 오려 붙혔더니 이쁘게 나오긴 하는데 링크걸리네요. -_- 누르지 마세요ㅎㅎ
첫댓글 고생많으십니다.ㅎㅎ
감사합니다... 근데 Console에서 명령을 넣다니..조금 생각과는 다른거 같네요.. 한번 해보겠습니다 ^^