socket_object.SendTo Method

Sends a message using an open UDP Socket.

...socket_object.SendTo(output_buffer, max_length, remote_endpoint )

Prerequisites

The Socket Object must be open for UDP I/O.

The Socket Object must have been created by the udpclient_object.Client method.

Parameters

output_buffer

The String value that is sent.

max_length

An optional value indicating the maximum number of data bytes to send. If omitted or zero, the entire output_buffer string is sent.

remote_endpoint

An IPEndPoint Object that contains endpoint information identifying the remote destination for the data sent.

Remarks

If blocking is enabled, this method blocks if the output queue is full.

This method returns the number of bytes of data actually sent. If that number is less than the number requested, you should re-issue the SendTo to output the remainder of the bytes.

If any network errors occur, this method throws an Exception.

Examples

Dim uc As New UdpClient()
Dim remote_ep As New IPEndPoint("192.168.0.5")
Dim sock As Socket
Dim output As String
Dim count As Integer
sock = uc.Client
count = sock.SendTo(output, 0, remote_ep)
...
count = sock.ReceiveFrom(input, 2000, remote_ep) ' Get new remote endpoint
...
count = sock.SendTo(output, 0, remote_ep) ' Reply to previous sender

See Also

Networking Classes | socket_object.Send