parrotcode: TCPStream | |
Contents | Libraries |
TCPStream
.sub main :main
load_bytecode 'library/tcpstream.pir'
.local pmc stream
stream = new 'TCPStream'
stream.'connect'("www.google.com", 80)
stream.'say'("GET / HTTP/1.0")
stream.'say'("User-agent: Parrot")
stream.'say'("")
$S0 = stream.'slurp'()
print $S0
stream.'close'()
.end
This is a high-level sockets library designed to mimic Tcl's socket builtins. As such, it uses print
and say
instaed of send
and readline
and slurp
instead of recv
.
init
init_pmc
get_bool
void close()
void connect(string host, int port)
void flush()
string readline()
void say(string msg)
msg
and an end-of-line character to the socket.string slurp()
Matt Diephouse <matt@diephouse.com>.
|