Dart.PowerTCP.SslSockets Namespace > Udp Class > Open Method : Open(IPEndPoint) Method |
Allocate a socket at the specified IPEndPoint for sending and receiving datagrams.
[Visual Basic]
<DescriptionAttribute("Opens the specified local system IP address/port")>
Overloads Public Sub Open( _
ByVal host As IPEndPoint _
)
[C#]
[DescriptionAttribute("Opens the specified local system IP address/port")]
public void Open(
IPEndPoint host
);
[C++]
[DescriptionAttribute("Opens the specified local system IP address/port")]
public: void Open(
IPEndPoint* host
)
[C++/CLI]
[DescriptionAttribute("Opens the specified local system IP address/port")]
public:
void Open(
IPEndPoint^ host
)
Exception | Description |
---|---|
SocketException | The local address is unknown, invalid, or unable to be resolved. |
ArgumentOutOfRangeException | The local port is out of the range of valid values. |
This method allocates a socket at the specified IPEndPoint for sending and receiving datagrams. Upon successful completion of this method, the local address and port are accessible through the LocalEndPoint property.
This method must be called in order to successfully use Receive or BeginReceive.
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
Udp Class | Udp Members | Overload List
Send comments on this topic.
Documentation version 1.1.2.0.
© 2008 Dart Communications. All rights reserved.