Method _Stdio.UDP()->send()


Method send

int send(string to, int|string port, string message)
int send(string to, int|string port, string message, int flags)

Description

Send data to a UDP socket.

Parameter to

The recipient address. For connect()ed objects specifying a recipient of either UNDEFINED or "" causes the default recipient to be used.

Parameter port

The recipient port number. For connect()ed objects specifying port number 0 casues the default recipient port to be used.

Parameter flag

A flag bitfield with 1 for out of band data and 2 for don't route flag.

Returns
(0..)

The number of bytes that were actually written.

(..-1)

Failed to send the message. Check errno() for the cause. Common causes are:

System.EMSGSIZE

The message is too large to send unfragmented.

System.EWOULDBLOCK

The send buffers are full.

Throws

Throws errors on invalid arguments and uninitialized object.

Note

Versions of Pike prior to 8.1.5 threw errors also on EMSGSIZE ("Too big message") and EWOULDBLOCK ("Message would block."). These versions of Pike also did not update the object errno on this function failing.

Note

Versions of Pike prior to 8.1.13 did not support the default recipient for connect()ed objects.

See also

connect(), errno(), query_mtu()