broke io::read/write out into non-buffering and buffering solutions

OK.  Here is the pull request which addresses issues #45, #46, and #47.   It is pretty large,  the IoEventCtx plays a more important role in things, since re-registration is so common.  I  renamed to IoEventCtx and added the Token to it, to simplify the interface into the the register functions. 

For an advanced example of how the event re-registration can actually help simplify a state machine, check out the revised test_echo_server. 

* more tweaks to make the tests pass, also made the return type uint instead of () so the customer doesn't have to go looking through the buffer for answers
* addressing issues 45, 46, and 47.  Added re-registration via an IoEventContext into the event_loop. Supports both edge triggered and level triggered setups.  
* Changed * net::read and write to not use a loop.. added read_all and write_all to use them and perform the old behavior
* got all tests passing
That's a good point. I'm not sure where this should happen, though because
net:: doesn't really know about file descriptors. Maybe it should go into
posix::
 On Nov 15, 2014 9:20 AM, "Ayose Cazorla" <notifications@github.com> wrote:

> In src/net.rs:
>
> > +        pub fn connect(&self, addr: &SockAddr) -> MioResult<()> {
> > +            debug!("socket connect; addr={}", addr);
> > +
> > +            // Attempt establishing the context. This may not complete immediately.
> > +            if try!(os::connect(&self.desc, addr)) {
> > +                // On some OSs, connecting to localhost succeeds immediately. In
> > +                // this case, queue the writable callback for execution during the
> > +                // next event loop tick.
> > +                debug!("socket connected immediately; addr={}", addr);
> > +            }
> > +
> > +            Ok(())
> > +        }
> > +
> > +        pub fn close(&self) -> MioResult<()> {
> > +          os::close(&self.desc)
>
> I think that the self.desc should be set to something equivalent to -1.
>
> A file descriptor number is reused by the kernel after closing it, so it
> is possible that a future read on a closed TcpSocket get data from
> another connection.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/carllerche/mio/pull/51/files#r20402565>.
>