848ba7303b
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
37 lines
909 B
Text
37 lines
909 B
Text
gopher:get
|
|
|
|
Data: asns-n
|
|
Addr: -
|
|
Float: -
|
|
|
|
Takes an address, a server, a port, and a selector. Fetch the
|
|
resource and store it at address. Return the number of bytes
|
|
received.
|
|
|
|
Class: class:word | Namespace: gopher | Interface Layer: ios
|
|
|
|
Example #1:
|
|
|
|
here 'forthworks.com #70 '/ gopher:get
|
|
here s:put
|
|
|
|
|
|
~~~
|
|
:set (asns-sns) 'abcd 'bcda reorder buffer:set ;
|
|
:url (sns-s) 'abc 'cba reorder 'gopher://%s:%n/0%s s:format ;
|
|
:command (s-s) 'curl_-s_%s s:format ;
|
|
:connect (s-p) file:R unix:popen ;
|
|
:read (p-p) [ dup file:read dup buffer:add n:zero? ] until ;
|
|
:complete (p-n) unix:pclose buffer:end buffer:start - ;
|
|
---reveal---
|
|
:gopher:get (asns-n)
|
|
[ set url command connect read complete ] buffer:preserve ;
|
|
~~~
|
|
|
|
## Test Case
|
|
|
|
~~~
|
|
'Data d:create #256001 allot
|
|
&Data 'forthworks.com #70 '/retro gopher:get
|
|
'%n_bytes_read\n s:format s:put
|
|
~~~
|