See Also

Udp Class  | Udp Members  | Overload List

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

buffer
A string containing the data to send.
host
The host address (either dot address or hostname) to send the datagram to.
port
A string (which is converted to an Integer) representing the host port to send the datagram to.
See Also Languages PowerTCP SSL Sockets for .NET

Send(String,String,String) Method

Dart.PowerTCP.SslSockets Namespace > Udp Class > Send Method : Send(String,String,String) Method

Send a datagram to the specified remote address and port.

[Visual Basic]
<DescriptionAttribute("Convert a string into a byte array and send it.")> Overloads Public Function Send( _    ByVal buffer As String, _    ByVal host As String, _    ByVal port As String _ ) As Datagram
[C#]
[DescriptionAttribute("Convert a string into a byte array and send it.")] public Datagram Send(    string buffer,    string host,    string port );
[C++]
[DescriptionAttribute("Convert a string into a byte array and send it.")] public: Datagram* Send(    string* buffer,    string* host,    string* port )
[C++/CLI]
[DescriptionAttribute("Convert a string into a byte array and send it.")] public: Datagram^ Send(    String^ buffer,    String^ host,    String^ port )

Parameters

buffer
A string containing the data to send.
host
The host address (either dot address or hostname) to send the datagram to.
port
A string (which is converted to an Integer) representing the host port to send the datagram to.

Return Type

A Datagram object encapsulating the datagram sent.

Exceptions

ExceptionDescription
ArgumentNullExceptionbuffer is null.
SocketExceptionThe remote address is unknown, invalid, or unable to be resolved.
ArgumentOutOfRangeExceptionThe remote port is out of the range of valid values.

Remarks

Use the Udp.Send method to sent a datagram created from the data contained in buffer to the specified host and port. buffer is converted to a byte array before sending.

A UDP datagram provides little functionality over an IP datagram, adding a port number field which allows multiplexing on the receiving host and checksum field which provides basic error handling. Unlike TCP, UDP datagrams are sent as a unit. If Udp.Send is called 3 times to send 3 datagrams to a host, the receiving host will have to call Receive 3 times. Also, the size of each datagram sent will equal the size of each datagram received by the receiving host. In addition, since UDP is a connectionless protocol, any datagrams sent to the host are not guaranteed to be delivered. Therefore, any required error checking (outside of UDP's checksum implementation) will have to be done by the application-layer protocol.

To send a broadcast datagram, use "255.255.255.255" as the remote address. To sent a multicast datagram, use the multicast group address as the remote address after first joining a multicast group by using Udp.JoinMulitcastGroup.

Example

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
* ---------------------
*/
                

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  | Overload List


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.