The following are functions that send data to a socket (ie, remote computer):

SockSend Sends a string to the connected computer.
SockSendTo Sends a datagram (string) to the connected computer.


SockSend

Sends data to an already-connected computer.

Calls the sockets library's send() function.

Synopsis

sent = SockSend(socket, data, flags)

Args

socket is the socket returned by SockSocket or SockAccept.

data is the data string to send.

flags is any (or none) of the following, separated by a space:

MSG_DONTROUTE The data should not be subject to routing.
MSG_OOB Send out-of-band data.

If omitted, defaults to none of the above.

Returns


The number of chars (bytes) actually sent. Could be 0 if an error.

Notes

The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.

For sockets of type "SOCK_DGRAM", care must be taken not to pass a string longer than the maximum IP packet size of the underlying subnets, which is returned by SockMaxPacketSize. If the data is too long, then ErrNo = "EMSGSIZE", and no data is transmitted.

The successful completion of SockSend does not indicate that the data was successfully delivered.

SockSend will likely block unless the socket has been placed in a non-blocking mode. On non-blocking SOCK_STREAM sockets, the number of bytes written may be between 1 and the requested length, depending on buffer availability on both the local and remote computers. SockSelect() may be used to determine when it is possible to send more data.


SockSendTo

Sends a datagram (string) to the connected computer.

Calls the sockets library's sendto() function.

Synopsis

sent = SockSendTo(socket, data, flags, 'addr.')

Args

socket is the socket returned by SockSocket or SockAccept.

data is the data string to send.

flags is any (or none) of the following, separated by a space:

MSG_DONTROUTE The data should not be subject to routing.
MSG_OOB Send out-of-band data.

If omitted, defaults to none of the above.

addr. is the name of the stem variable whose tails, addr.FAMILY, addr.PORT, and addr.ADDR you must set to the Address Family, Port number, and dotted IP address of the peer to whom you wish to send the data string.

Returns


The number of bytes (characters) actually sent. Could be 0 if an error.

Notes

The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.

See notes under SockSend.

Although SockSendTo is primary to send a string to a socket of type SOCK_DGRAM, it can also be used to send a string to a socket of type SOCK_STREAM. But in the later case, addr. is ignored.

To send a broadcast (on a type "SOCK_DGRAM" socket only), addr.ADDR should be set to the special IP address "INADDR_BROADCAST", and addr.PORT should be set to the intended port number. It is generally inadvisable for a broadcast datagram to exceed the size at which fragmentation may occur, which implies that each string you send to a SOCK_DGRAM socket should not exceed 512 bytes.