PowerTCP Sockets for .NET
GetEchoes Method (PingSlave)
Example 




The host where the Echo request is sent (can be a broadcast address).
The data to send in the Echo request. Can be null.
The maximum number of hops the request should take before expiring.
The number of milliseconds to wait for responses to arrive.
If true, multiple socket receives will be used until the socket times out. If false, only one socket receive is used.
Send an ICMP Echo request and block until all responses are received.
Syntax
'Declaration
 
Public Function GetEchoes( _
   ByVal address As IPAddress, _
   ByVal data() As Byte, _
   ByVal ttl As Integer, _
   ByVal timeout As Integer, _
   ByVal broadcast As Boolean _
) As Echo()
'Usage
 
Dim instance As PingSlave
Dim address As IPAddress
Dim data() As Byte
Dim ttl As Integer
Dim timeout As Integer
Dim broadcast As Boolean
Dim value() As Echo
 
value = instance.GetEchoes(address, data, ttl, timeout, broadcast)
public Echo[] GetEchoes( 
   IPAddress address,
   byte[] data,
   int ttl,
   int timeout,
   bool broadcast
)
public: Echo*[]* GetEchoes( 
   IPAddress* address,
   byte[]* data,
   int ttl,
   int timeout,
   bool broadcast
) 
public:
array<Echo^>^ GetEchoes( 
   IPAddress^ address,
   array<byte>^ data,
   int ttl,
   int timeout,
   bool broadcast
) 

Parameters

address
The host where the Echo request is sent (can be a broadcast address).
data
The data to send in the Echo request. Can be null.
ttl
The maximum number of hops the request should take before expiring.
timeout
The number of milliseconds to wait for responses to arrive.
broadcast
If true, multiple socket receives will be used until the socket times out. If false, only one socket receive is used.

Return Value

One or more Echo responses.
Remarks

This method will block until it times out while performing a socket receive.

Ping broadcasting is supported when Type is set to Type.Raw. When set to Type.System, only the first responding system is returned.

Example
The following example demonstrates pinging a remote host.
private void button1_Click(object sender, EventArgs e)
{
    ping1.Start(pingWorker, HostNameOrAddressToPingTextbox.Text);
}

private void pingWorker(PingSlave slave, object state)
{
    ping1.Marshal(slave.GetEchoes(new Dart.Sockets.IPEndPoint(state.ToString(), 0).Address, null, 20, 5000, false));
}

void ping1_Echo(object sender, EchoEventArgs e)
{
    string results = "The following echoes were returned:\r\n";
    for (int i = 0; i < e.Echoes.Length; i++)
        results += e.Echoes[i].ToString() + "\r\n";
    textBox1.AppendText(results);
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    ping1.Start(AddressOf pingWorker, HostNameOrAddressToPingTextbox.Text)
End Sub

Private Sub pingWorker(ByVal slave As PingSlave, ByVal state As Object)
    ping1.Marshal(slave.GetEchoes((New Dart.Sockets.IPEndPoint(state.ToString(), 0)).Address, Nothing, 20, 5000, False))
End Sub

Private Sub ping1_Echo(ByVal sender As Object, ByVal e As EchoEventArgs)
    Dim results As String = "The following echoes were returned:" & vbCrLf
    For i As Integer = 0 To e.Echoes.Length - 1
        results &= e.Echoes(i).ToString() & vbCrLf
    Next i
    textBox1.AppendText(results)
End Sub
See Also

Reference

PingSlave Class
PingSlave Members


PowerTCP Sockets for .NET Documentation Version 4.5
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic