hi i need a sample for vb how to ping a host using icmp class in the aspose.network components
thanks in advance
Ivano Panichelli
hi i need a sample for vb how to ping a host using icmp class in the aspose.network components
thanks in advance
Ivano Panichelli
Hello Ivano,
Thank you for your post!
There's an asynchrounous ping sample included in our setup package. And here's a VB sample of how to ping a host machine using Aspose.Network:
'Aspose.Network.Icmp.client
Dim client As EchoClient
'bytes to send using client
Dim bytesToSend() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Dim Host As String = "www.aspose.com"
Try
client = New EchoClient(Host)
'time out in 3 seconds
client.ReceiveTimeout = 3000
Catch ie As IcmpException
' "cannot resolve name to ip address" exception will be catched here
' if inputString cannot be resolved to ip address
Console.WriteLine(ie)
' press any key to terminate program
Console.Read()
Return
End Try
'ping result
Dim pingResult As Aspose.Network.Icmp.EchoReplyMessage
Try
Console.WriteLine("pinging " & Host & " with 32 bytes of data")
'send ping message
pingResult = client.Echo(New EchoMessage(bytesToSend))
If pingResult IsNot Nothing Then
'If target machine replied our ping message
Console.WriteLine("replied from host")
End If
Catch ie As IcmpException
'If host does not respond in a timely fashion, exception will be catched here
Console.WriteLine(ie)
End Try
Console.Read()
Best regards.