Previous section To contents Next section

9.5 UDP socket and message management - Stdio.UDP

CLASS
Stdio.UDP

SYNTAX
Stdio.UDP();

DESCRIPTION
Stdio.UDP is the way of transceiving UDP from Pike.

SEE ALSO
Stdio.File

METHOD
Stdio.UDP.bind

SYNTAX
bind(int port); bind(int port,string address);

DESCRIPTION
binds a port for recieving or transmitting UDP

RETURNS
the called object

METHOD
Stdio.UDP.enable_broadcast

SYNTAX
enable_broadcast()

DESCRIPTION
enable transmission of broadcasts. This is normally only avalable to root users.

RETURNS
1 upon success, 0 otherwise

METHOD
Stdio.UDP.read

SYNTAX
read()
read(int flags)

DESCRIPTION
read from the UDP socket. Flags is a bitfield, 1 for out of band data and 2 for peek.

RETURNS
mapping(string:int|string) in the form
([
   "data" : string recieved data
   "ip" : string   recieved from this ip
   "port" : int    ...and this port
])

SEE ALSO
Stdio.UDP.set_nonblocking and Stdio.UDP.set_read_callback

METHOD
Stdio.UDP.send

SYNTAX
send(string to_addr,int to_port,string data)
send(string to_addr,int to_port,string data,int flags)

DESCRIPTION

RETURNS
number of bytes sent

METHOD
Stdio.UDP.set_nonblocking

SYNTAX
set_nonblocking();
set_blocking();
set_nonblocking(function, mixed ...);

DESCRIPTION
sets this object to be nonblocking or blocking. If set_nonblocking is given with argument, these are passed to set_read_callback().

RETURNS
the called object

METHOD
Stdio.UDP.set_read_callback

SYNTAX
set_read_callback(function(mapping(string:int|string), mixed...), mixed ... extra);

DESCRIPTION
The called function is recieving mapping similar to the return value of read:
([
   "data" : string recieved data
   "ip" : string   recieved from this ip
   "port" : int    ...and this port
])

RETURNS
the called object

METHOD
Stdio.UDP.query_address

SYNTAX
query_address()

DESCRIPTION

RETURNS
the current address in format "<ip> <port>".

SEE ALSO
Stdio.File.query_address

Previous section To contents Next section