{ $description "Waits up to " { $snippet "ms" } " milliseconds for pending I/O requests to complete." }
{ $warning "If an I/O request completes during the time period, its continuation is resumed and the current one is not saved. If you need to delay execution for a period of time, use the higher-level " { $link sleep } " word instead." } ;
{ $values { "host" string } { "port" "an integer between 0 and 65535" } { "stream" "a bidirectional stream" } }
{ $description "Opens a TCP/IP connection to port number " { $snippet "port" } " on the host named by " { $snippet "host" } ", and outputs a bidirectional stream." }
{ $description "Waits for a connection to a server socket created by " { $link <server> } ", and outputs a bidirectional stream when the connection has been established."
{ $values { "port" "an integer between 0 and 65535" } { "datagram" "a handle" } }
{ $description "Creates a UDP/IP socket listening on " { $snippet "port" } ". The returned object responds to three words:"
{ $list
{ { $link stream-close } " - stops listening on the port and frees all associated resources" }
{ { $link receive } " - waits for a UDP/IP packet" }
{ { $link send } " - sends a UDP/IP packet" }
}
}
{ $errors "Throws an error if the port is already in use, or if the OS forbids access." } ;
HELP: receive
{ $values { "datagram" "a datagram socket" } { "packet" byte-array } { "host" string } { "port" "an integer between 0 and 65535" } }
{ $description "Waits for an incoming UDP/IP packet on the given datagram socket. Outputs the packet data, as well as the sender's host name and port number." }
{ $errors "Throws an error if the packet could not be received." } ;
HELP: send
{ $values { "packet" byte-array } { "host" string } { "port" "an integer between 0 and 65535" } { "datagram" "a datagram socket" } }
{ $description "Sends a UDP/IP packet to the given datagram socket." }
{ $errors "Throws an error if the packet could not be sent." } ;
{ $error-description "This error is thrown when C stream I/O is in use and one of the TCP/IP networking words is called. C stream I/O will be in use if either the " { $snippet "-no-native-io" } " switch is passed to bootstrap (see " { $link "bootstrap-cli-args" } ") or if Factor does not have a native I/O implementation for your operating system." } ;