Giter VIP home page Giter VIP logo

mob's Introduction

mob

A multi-echo server written in Rust using the mio async-io library.

Build Status

  • master branch is currently setup to work against the master branch of mio (aka 0.6.0-dev)
  • 0.5 branch is setup to work against the 0.5 branch of mio

Install

Run cargo build to build both mob-server and mob-client.

Client

The client is just a very simple way to send a bunch of messages to the server.

Logging

I use the env_logger crate. Logging can be turned on for mob-server with:

RUST_LOG=mob_server ./target/debug/mob-server  

If you want to see the log output from mio as well, you can do:

RUST_LOG=mob_server,mio ./target/debug/mob-server

Docker

docker run --rm -it -v $(pwd):/source schickling/rust cargo run --bin mob-server

mob's People

Contributors

hjr3 avatar pjvds avatar salpalvv avatar simbo1905 avatar tairrzayev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mob's Issues

Convert into library

Remove the need for a main function. I will use an examples directory for some concrete implementations. This should also allow for easier test writing.

Write tests

Especially using a barrier between the client and server.

Manage state better

we have three types of state:

  • socket state - basically a boolean that tells us if the connection is reset or not
  • event state - tells us whether we need to register, reregister or do nothing. typically people think mio handles this for us, but it really doesn't. also, the goal is to not call reregister a bunch of times because syscalls are expensive relative to updating a field in a struct
  • read/write state - tells us whether we are in the middle of a read/write or not
    • in the case of read, we need to keep track of how much we need to read
    • Question: my handler first handles writes then reads. if my write gets EAGAIN (WouldBlock) is there any point in trying to read? I think the answer is yes because those are different buffers.

Separate event loop handler from server

  • remove slab from server
  • server is now just a simple case of a Connection type
  • handler should branch on token first (server connection or not), then events

Explain idle / reset connections.

Hi Thanks for the code example.
It is the only solid example of mio that I could find using the new api.

This is probably me being dumb but could maybe explain the code in the "ready" function of the server
line 121.

I can't quite grasp why connections are reset and made idle. Then at the end of each tick with try to re-register the connection. Could you please elaborate why we do that ?
Where do connections become unregistered ?

Thanks

About OneShot PollOpt

Hello, first of all, really good example on mio. i have one confusion though.

1 ) Do we really need to reregister again and again? i think you used PollOpt:: Oneshot, that is why you are reregistering every time. or that is not that case and we need to reregister every time.

2 ) How to read data from soocket to vec![u8; 1024]
I am able to read data from socket to [u8; 1024] array, but when i try to use vec as variable buffer to store data on heap, it is not reading from socket to vec. plesae if possible give an example.

3 ) How to track if socket is closed from client side, do we get any notification in MIO ?

thank you in advance.

Does not compile

cargo build does not compile.

Steps to reproduce: clone the repository and enter the command.

Used version: rust 1.8.0 and rustc 1.10.0-nightly (2174bd97c 2016-04-14)

mob-client threads start hanging on windows

First off, I'd like to thank you for creating this project. I'm very new to Rust, and found this project through your blog post which was linked from the MIO project. It has been very helpful as a hands-on example and launching point.

Secondly, I'm not sure if this is a bug in "mob" or MIO. If you think this is a MIO bug I'll be glad to re-report the bug there.

Essentially the bug is that when running both mio-server and mio-client (built from the master branch) on my Windows machine, all but one of the client threads start hanging. As far as I can tell from adding println!s, they are blocked trying to read from the server.

I set up an Ubuntu VM on the hunch that the issue was OS-specific, and sure enough, it works fine on Ubuntu.

Server crashes during benchmarking.

Hi,

I wanted to use your server as benchmark point for mioco. Unfortunately it does not survive the benchmark.

[futex:mio/mob] (master)% cargo run --release --bin mob-server
   Compiling slab v0.1.1
   Compiling libc v0.1.8
   Compiling bitflags v0.1.1
   Compiling bytes v0.2.10
   Compiling regex-syntax v0.2.1
   Compiling nix v0.3.9
   Compiling winapi v0.1.23
   Compiling log v0.3.1
   Compiling memchr v0.1.3
   Compiling clock_ticks v0.0.5
   Compiling aho-corasick v0.3.0
   Compiling mio v0.4.1
   Compiling regex v0.1.41
   Compiling env_logger v0.3.1
   Compiling mob v0.1.0 (file:///home/dpc/lab/rust/mio/mob)
     Running `target/release/mob-server`
ERROR:mob_server::connection: Failed to send buffer for Token(9), error: Connection reset by peer (os error 104)
ERROR:mob_server::connection: Failed to send buffer for Token(10), error: Connection reset by peer (os error 104)
ERROR:mob_server::connection: Failed to send buffer for Token(11), error: Connection reset by peer (os error 104)
ERROR:mob_server::connection: Failed to send buffer for Token(11), error: Connection reset by peer (os error 104)
thread '<main>' panicked at 'invalid index', ../src/libcore/option.rs:330
An unknown error occurred

To learn more, run the command again with --verbose.

The benchmark itself is: https://github.com/dpc/benchmark-echo , and as it works fine against mioco, libev, and node tcp server implementation, I guess it's OK. I start it with ./benchmark.sh 8000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.