client-ip tcp-output-argument
Returns the IP address of the client
connected to a TCP port. The tcp-output-argument is the second value
returned from socket-accept . The address is returned as a string, the same as
the third result from socket-accept .
|
>(let s (socket-accept (open-socket 8080))
(client-ip (s 1)))
"10.2.40.71"
|
open-socket port
Opens a tcp-listener on the given port.
|
>(open-socket 8000)
#<tcp-listener>
|
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
(input-port output-port client-ip-string) .
|
>(socket-accept (open-socket 8080))
(#<input-port> #<output-port> "10.2.40.71")
|
w/socket var port [body ...]
Opens a socket with open-socket , assigns it to var , executes body , and closes the socket.
|
>(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
|
Copyright 2008 Ken Shirriff.