Function SocketSendTo() Professional

Sends data to a specific destination.

Syntax
SocketSendTo( <nSocket>  , ;
              <cBuffer>  , ;
              [<nLength>], ;
              [<nFlag>]  , ;
              [<aToAddr>], ;
              [@<nError>]  ) --> nBytesWritten
Parameters
<nSocket>
This is a numeric socket descriptor identifying a socket.
<cBuffer>
This is a character string holding the data to send.
<nLength>
Optionally, the number of bytes to send can be specified. This parameter defaults to Len(<cBuffer>).
<nFlag>
#define constants from the file SOCKET.CH are used for this parameter. It specifies the way in which the call is made.
Constants for sending data.
Constant Description
MSG_NORMAL *) Sends regular data
MSG_DONTROUTE Specifies that the data should not be subject to routing.
MSG_OOB Sends out-of-band data (SOCK_STREAM only)
  1. default
<aToAddr>
Optionally, an array containing IP address information of the recipient of the data can be specified. This array can be retrieved via SocketGetPeerName(), or the array assigned to the reference parameter <aFromAddr> of the function SocketRecvFrom() can be used to respond to a sender of a message.
<nError>
If this parameter is passed by reference to the function, it gets assigned a numeric error code when the function fails. #define constants beginning with WSAE are available in the file SOCKET.CH to identify an error condition.
Return

The function returns the number of bytes written to socket.

Description

This function is typically used to send datagrams on unconnected sockets to a recipient. However, the function can be called on any datagram socket, be it connected or unconnected. If the socket is unbound, unique values are assigned to the local association by the operating system, and the socket is then marked as bound. Note that the successful completion of a SocketSendTo() does not indicate that the data was successfully delivered.

To send to a broadcast address, an application must have called SocketSetOption() with SO_BROADCAST enabled. Otherwise, SocketSendTo() will fail on broadcast messages.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.