Closed aloucks closed 4 years ago
It looks like something was already using port 5555. If not, we're looking for people to help us fix Windows problems. eg. https://github.com/carllerche/mio/issues/367 .
I'll be happy to help, but I don't have Windows box, so I'm unable to help.
The port was definitely not in use. The echo server starts up without issue; the error occurs as soon as a client connection is made. Probably related: https://github.com/carllerche/mio/issues/334
I got this error when trying to read and write on the same socket from two different coroutines. Is the code made to support this?
Mioco code yes. But it's an mio windows error. I've recently maidsafe devs were hunting mio errors on windows, so we need to wait for these to get merged mainstream, them upgrade mioco's mio dependency.
I was on linux when the bug occured. What I did was open 2 TcpStreams, clone them, spawn 2 coroutines, and pipe one socket into another in each coroutine, essentially joining the sockets together. It was panicking pretty often with the "socket already registered" error.
Can you share the code? Probably mioco bug then.
It looks like this
let mut remote: TcpStream = ...;
let mut origin = try!(TcpStream::connect(&addr));
let mut remote2 = try!(remote.try_clone());
let mut origin2 = try!(origin.try_clone());
mioco::spawn(move || -> io::Result<()> {
let mut buf = [0; 1024];
loop {
let size = try!(remote2.read(&mut buf));
if size == 0 {
break;
}
origin2.write_all(&buf[..size]);
}
Ok(())
});
mioco::spawn(move || -> io::Result<()> {
let mut buf = [0; 1024];
loop {
let size = try!(origin.read(&mut buf));
if size == 0 {
break;
}
remote.write_all(&buf[..size]);
}
Ok(())
});
mioco v0.4.1