Use til-pkg to install it easily:
$ til install socket
socket.tcp.server "*" 8000 | foreach connection {
spawn {
autoclose $connection
print "new connection: $connection"
receive $connection | to.string | as data
print " received: $data"
to.byte_vector "pong: $data" | send $connection
}
}