Skip to content

class UDPSocketUnconnected

  • supers: UDPSocketGeneric

methods


UDPSocketUnconnected.receivefrom


function UDPSocketUnconnected.receivefrom(size: number?)
 -> datagram Datagram?
 -> ip_or_err (string|"timeout")
 -> port number

@return ip_or_err - IP address or 'timeout' error string

Works exactly as the receive method, except it returns the IP address and port as extra return values (and is therefore slightly less efficient)

UDPSocketUnconnected.sendto


function UDPSocketUnconnected.sendto(
  datagram: Datagram,
  ip: string,
  port: number
)
 ->  SocketReturnResult
 ->  SocketReturnError

Sends a datagram to the specified IP address and port number.

Datagram is a string with the datagram contents. The maximum datagram size for UDP is 64K minus IP layer overhead. However datagrams larger than the link layer packet size will be fragmented, which may deteriorate performance and/or reliability. Ip is the IP address of the recipient. Host names are not allowed for performance reasons. Port is the port number at the recipient.

If successful, the method returns 1. In case of error, the method returns nil followed by an error message.

Note: In UDP, the send method never blocks and the only way it can fail is if the underlying transport layer refuses to send a message to the specified address (i.e. no interface accepts the address).