Dart.PowerTCP.SslSockets Namespace > Udp Class > Open Method : Open(String,Int32) Method |
Allocate a socket at the specified address and port for sending and receiving datagrams.
[Visual Basic]
<DescriptionAttribute("Opens the specified local system IP host/port")>
Overloads Public Sub Open( _
ByVal host As String, _
ByVal port As Integer _
)
[C#]
[DescriptionAttribute("Opens the specified local system IP host/port")]
public void Open(
string host,
int port
);
[C++]
[DescriptionAttribute("Opens the specified local system IP host/port")]
public: void Open(
string* host,
int port
)
[C++/CLI]
[DescriptionAttribute("Opens the specified local system IP host/port")]
public:
void Open(
String^ host,
int port
)
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 address and port for sending and receiving datagrams. host can either be dot address or a hostname (which is resolved to a dot address). 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...
[Visual Basic]
' Begin listening on the specified port and address
Udp1.Open("MyHostName", 8888)
' Send a broadcast to all hosts on the network on port 8888
Udp1.Send("hello everyone", "255.255.255.255", "8888")
' Receive the broadcast datagram.
Dim buffer(Udp1.BufferSize) As Byte
Debug.WriteLine(System.Text.Encoding.Default.GetString(buffer))
' Display data
Debug.WriteLine(d.ToString())
'* Output
'* ---------------------
'* hello everyone
'* ---------------------
'*
[C#]
// Begin listening on the specified port and address
udp1.Open("MyHostName", 8888);
// Send a broadcast to all hosts on the network on port 8888
udp1.Send("hello everyone", "255.255.255.255", "8888");
// Receive the broadcast datagram.
byte[] buffer = new byte[udp1.BufferSize];
udp1.Receive(buffer);
// Display data
Debug.WriteLine(System.Text.Encoding.Default.GetString(buffer));
/* Output
* ---------------------
* hello everyone
* ---------------------
*/
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.