Skip to content

tcp socket

Turtle Kitty edited this page Jan 28, 2016 · 2 revisions

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.

listener messages

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

socket messages

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

Clone this wiki locally