See Also

Udp Class  | Udp Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerTCP SSL Sockets for .NET

Close Method

Dart.PowerTCP.SslSockets Namespace > Udp Class : Close Method (Udp)

Close the socket.

[Visual Basic]
<DescriptionAttribute("Close the socket.")> Public Sub Close()
[C#]
[DescriptionAttribute("Close the socket.")] public void Close();
[C++]
[DescriptionAttribute("Close the socket.")] public: void Close();
[C++/CLI]
[DescriptionAttribute("Close the socket.")] public: void Close();

Remarks

This method is the recommended way to close a socket (stop listening for datagrams). The Udp1.Active property is set to false when the socket is closed.

Example

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")
  }
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Udp Class  | Udp Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.