Dart.PowerTCP.SslSockets Namespace > Udp Class : ActiveChanged Event (Udp) |
Raised when the value of the Object.Active property changes.
[Visual Basic]
<CategoryAttribute("Property Changed")>
<DescriptionAttribute("Raised when the value of the Active property changes.")>
Public Event ActiveChanged() As EventHandler
[C#]
[CategoryAttribute("Property Changed")]
[DescriptionAttribute("Raised when the value of the Active property changes.")]
public event EventHandler ActiveChanged();
[C++]
[CategoryAttribute("Property Changed")]
[DescriptionAttribute("Raised when the value of the Active property changes.")]
public: __event EventHandler* ActiveChanged();
[C++/CLI]
[CategoryAttribute("Property Changed")]
[DescriptionAttribute("Raised when the value of the Active property changes.")]
public:
event EventHandler^ ActiveChanged();
This event is raised when the value of the Object.Active property changes, which occurs when the object (usually either the Server component or Udp component) either begins listening or stops listening for connections. Inside the event, check the Object.Active property see determine if the event which is the case.
This event is useful because it allows action to be taken (for example, disabling or enabling GUI elements) based on whether the object is actively listening or closed.
The following example demonstrates the Udp.ActiveChanged event
[Visual Basic]
Private Sub ActiveChangedTest()
' Create an IPEndPoint
Dim ep As System.Net.IPEndPoint = New System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.0.71"), 1111)
' Begin listening on the specified endpoint. The ActiveChanged event should be raised.
Udp1.Open(ep)
' Stop listening. The ActiveChanged event should be raised again.
Udp1.Close()
End Sub
Private Sub Udp1_ActiveChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Udp1.ActiveChanged
If Udp1.Active Then
Debug.WriteLine("Listening on " + Udp1.LocalEndPoint.ToString())
Else
Debug.WriteLine("Not Listening")
End If
End Sub
[C#]
private void ActiveChangedTest()
{
// Create an IPEndPoint
System.Net.IPEndPoint ep = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.0.71"), 1111);
// Begin listening on the specified endpoint. The ActiveChanged event should be raised.
udp1.Open(ep);
// Stop listening. The ActiveChanged event should be raised again.
udp1.Close();
}
private void udp1_ActiveChanged(object
sender, System.EventArgs e)
{
if(udp1.Active)
Debug.WriteLine("Listening on " + udp1.LocalEndPoint.ToString());
else
{
Debug.WriteLine("Not Listening")
}
}
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Send comments on this topic.
Documentation version 1.1.2.0.
© 2008 Dart Communications. All rights reserved.