-
Notifications
You must be signed in to change notification settings - Fork 4
tcp socket
A tcp-socket is a special port that can speak to the network. It is bidirectional, so supports the methods of both input and output ports.
Sockets come from two places: sys.tcp.connect, or the accept method of a tcp-listener created by sys.tcp.listen.
x.type -> 'tcp-listener
x.to-bool -> true
x.port -> returns the port number of the listener
x.ready? -> true if there is a connection ready to be accepted
x.accept -> accepts a connection and returns a socket
x.close -> shut down the TCP listener
x.read, x.read-rune, x.peek-rune, x.assert-rune, x.read-line, x.ready?, x.skip, x.skip-while, x.skip-until, x.read-token, x.read-token-while, x.read-token-until, x.read-token-if -> see stream
x.type -> 'socket
x.to-bool -> true
x.local-addr -> local IP address of the socket
x.local-port -> local port number of the socket
x.remote-addr -> remote IP address of the socket
x.remote-port -> remote port number of the socket
x.close -> close the socket