Skip to content

Instantly share code, notes, and snippets.

@sbillig sbillig/gist:5272756

forked from thomaslee/gist:4753338
Last active Dec 15, 2015
What would you like to do?
Dumb "Hello World" TCP server in Rust. Updated for Rust 0.6
extern mod std;
use std::net;
use std::uv;
type ErrChan = comm::SharedChan<Option<net::tcp::TcpErrData>>;
fn on_ready(_kill_ch: ErrChan) {
io::println("listener is ready");
fn on_connect(c: net::tcp::TcpNewConnection, kill_ch: ErrChan) {
do task::spawn() {
let res = net::tcp::accept(c);
if !res.is_err() {
let sck = result::unwrap(res);
let s = ~"Hello World\r\n";
} else {
fn main() {
let ip = net::ip::v4::parse_addr("");
let iotask = &uv::global_loop::get();
net::tcp::listen(ip, 9123, 128, iotask, on_ready, on_connect);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.