-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnetworking.tem
26 lines (26 loc) · 1.31 KB
/
networking.tem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(page "Networking"
(newtable "Networking"
(text "Arc's networking functions are limited to those necessary to support a
web server. In particular, there is no support for outgoing network
connections.")
(op client-ip "tcp-output-argument" "Returns the IP address of the client
connected to a TCP port. The <code>tcp-output-argument</code> is the second value
returned from <code>socket-accept</code>. The address is returned as a string, the same as
the third result from <code>socket-accept</code>."
(faketest
"(let s (socket-accept (open-socket 8080))
(client-ip (s 1)))" "\"10.2.40.71\"")
)
(op open-socket "port" "Opens a tcp-listener on the given port."
(tests (open-socket 8000)))
(op socket-accept "tcp-port" "Accepts a connection on the given tcp-listener.
The thread blocks until a connection is received. It returns a list of
<code>(input-port output-port client-ip-string)</code>."
(faketest "(socket-accept (open-socket 8080))"
"(#<input-port> #<output-port> \"10.2.40.71\")" )
)
(mac w/socket "var port [body ...]" "Opens a socket with <code>open-socket</code>, assigns it to <code>var</code>, executes <code>body</code>, and closes the socket." (faketest "(w/socket s 8888 (let (i o ip) (socket-accept s)
(w/stdout o (prn \"Hello\") (close i o))
(prn ip)))" "127.0.0.1"))
)
)