(index ("udp-open-socket" 0) ("udp-open-socket*" 0) ("udp-bind!" 613) ("udp-connect!" 1504) ("udp-send" 1790) ("udp-sendto" 2064) ("udp-recv" 2250) ("udp-recvfrom" 2536) ("udp-close-socket" 2759) ("udp-socket?" 2855) ("udp-bound?" 2971) ("udp-connected?" 3103) ("udp-bound-port" 3294))
(def (sig (procedure "(udp-open-socket [family])" (id udp-open-socket)) (procedure "(udp-open-socket* [family])" (id udp-open-socket*))) (p "Returns a new UDP socket object, which is simply a datagram " (tt "socket") " object created by the " (int-link "/egg/socket" "socket") " egg.") (p "The optional argument " (i "family") " can be " (tt "'inet") " for IPv4 or " (tt "'inet6") " for IPv6; the default is " (tt "'inet") ".") (p "(Note: The starred version is provided for API compatibility; it is exactly the same as the unstarred version, as all sockets in the socket egg are nonblocking at the OS level.)"))
(def (sig (procedure "(udp-bind! SOCKET HOST PORT)" (id udp-bind!))) (p "Binds a UDP socket to an address and port as specified by " (tt "HOST") " and " (tt "PORT") ".  " (tt "HOST") " may be a string consisting of an IP address or hostname, or " (tt "#f") ", in which case the unspecified address is used.  If " (tt "PORT") " is 0, a port will be allocated by the system automatically.") (p "To use IPv6, create a UDP socket with family " (tt "'inet6") ".  If the socket is in the IPv4 address family, as is the default, binding to an IPv6 address will raise an exception.  Example:") (pre "(define s (udp-open-socket 'inet6))\n(udp-bind! s \"::\" 1337)") (p "Binding to the unspecified IPv6 address \"::\" may, depending on your OS, also allow connections via IPv4.  See " (tt "socket-bind") " in the " (int-link "/egg/socket" "socket") " egg for an example of disabling this behavior."))
(def (sig (procedure "(udp-connect! SOCKET HOST PORT)" (id udp-connect!))) (p "Connect a socket.  In the case of UDP this does nothing more than associate a peer address with the socket in the kernel for use with later calls to " (tt "send(2)") ".  UDP is a connectionless protocol."))
(def (sig (procedure "(udp-send SOCKET STRING)" (id udp-send))) (p "Send the bytes in " (tt "STRING") " through " (tt "SOCKET") " to its peer, as specified with a previous call to " (tt "udp-connect!") ".  If the socket is not connected, the system will return an error."))
(def (sig (procedure "(udp-sendto SOCKET HOST PORT STRING)" (id udp-sendto))) (p "Send the bytes in " (tt "STRING") " through " (tt "SOCKET") " to " (tt "PORT") " on " (tt "HOST") "."))
(def (sig (procedure "(udp-recv SOCKET LENGTH)" (id udp-recv))) (p "Receive a packet of " (i "up to") " " (tt "LENGTH") " bytes, blocking the current thread until data is available.") (p "Returns two values: the number of bytes received and a string containing the message received."))
(def (sig (procedure "(udp-recvfrom SOCKET LENGTH)" (id udp-recvfrom))) (p "Same as " (tt "udp-recv") " except that two additional values are returned: the host string and port number from which the packet was received."))
(def (sig (procedure "(udp-close-socket SOCKET)" (id udp-close-socket))) (p "Close a socket."))
(def (sig (procedure "(udp-socket? THING)" (id udp-socket?))) (p "Test whether " (tt "THING") " is a UDP socket."))
(def (sig (procedure "(udp-bound? SOCKET)" (id udp-bound?))) (p "Test whether a UDP socket is bound to a local address and port."))
(def (sig (procedure "(udp-connected? SOCKET)" (id udp-connected?))) (p "Test whether a peer address and port has been associated with a UDP socket with a call to " (tt "udp-connect!") "."))
(def (sig (procedure "(udp-bound-port SOCKET)" (id udp-bound-port))) (p "Returns the port to which the socket is bound."))
