with-client ( remote encoding quot -- )
Networking ยป Connection-oriented networking

Prev:<client> ( remote encoding -- stream local )
Next:with-local-address ( addr quot -- )


Vocabulary
io.sockets

Inputs
remotean address specifier
encodingan encoding descriptor
quota 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


Definition