Guest User

Untitled

a guest
Oct 24th, 2012
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. extern mod std;
  2. use std::net::tcp;
  3. use std::net::ip;
  4. use std::uv;
  5.  
  6. fn main(){
  7. tcp::listen( ip::v4::parse_addr("127.0.0.1"), 4000, 100, uv::global_loop::get(),
  8. |_comm_chan|{
  9. error!("Server is listening");
  10. },
  11. |new_client, _comm_chan|{
  12. error!("New client");
  13. let result = tcp::accept(new_client);
  14. if result.is_ok(){
  15. error!("Accepted!");
  16. let socket = result::unwrap(move result);
  17. // Now do stuff with this socket
  18. }else{
  19. error!("Not accepted!");
  20. }
  21.  
  22. });
  23. }
Advertisement
Add Comment
Please, Sign In to add comment