Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern mod std;
- use std::net::tcp;
- use std::net::ip;
- use std::uv;
- fn main(){
- tcp::listen( ip::v4::parse_addr("127.0.0.1"), 4000, 100, uv::global_loop::get(),
- |_comm_chan|{
- error!("Server is listening");
- },
- |new_client, _comm_chan|{
- error!("New client");
- let result = tcp::accept(new_client);
- if result.is_ok(){
- error!("Accepted!");
- let socket = result::unwrap(move result);
- // Now do stuff with this socket
- }else{
- error!("Not accepted!");
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment