with-client ( remote encoding quot -- ) (original) (raw)

Vocabulary
io.sockets

Inputs

remote an address specifier
encoding an encoding descriptor
quot a quotation

Outputs
None

Word description
Opens a network connection and calls the quotation in a new dynamic scope with input-stream and output-stream rebound to the network streams. The local address the socket is connected to is stored in the local-address variable, and the remote address is stored in the remote-address variable.

Errors
Throws an error if the connection cannot be established.

Examples

T{ inet f "www.factorcode.org" 80 } ascii [ "GET / HTTP/1.1\r\nhost: www.factorcode.org\\r\\n\\r\\n" write flush read-?crlf ] with-client

See also
, spawn-client

Definition