0

Can I create the same server as Server or Client with different sockets?

Like A -> B -> C

Here, A is a client of server B, B is a server to A but a client of server C.

How can I register both of these in the same MIO event_loop?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
M Harry
  • 39
  • 3
  • Welcome to Stack Overflow! It is expected that you [show that you tried something](http://stackoverflow.com/help/how-to-ask), whether it is a (**minimal**) snippet of code that doesn't work or links to research you have done. SO isn't a service where people write code for you. – Shepmaster Nov 30 '15 at 14:41
  • 2
    Related [post](https://users.rust-lang.org/t/mio-can-anyone-explain-me-mio-with-diagram-please/3822) from you on users.rust-lang.org. Have you checked out the examples in the mio-repository? There's the [echo server example](https://github.com/carllerche/mio/blob/master/test/test_echo_server.rs). It's self-contained and can probably be used as a starting point. – oli_obk Nov 30 '15 at 14:49
  • AFAICS, The echo server example is event based with all events originating at the client. The server can only send messages in response to a client message. I don't think this model works well for an IRC server or a computer game, so it doesn't probably cover Harrys example. Is it possible to separate a net::TcpStream in to a Sender and a Receiver that can be connected to mio separately? Or do you need two TcpConnections? (If someone has an answer, please write it here. I would also like to know.) – nielsle Dec 05 '15 at 17:07
  • Reply to self. mio-websockets seems to be aimed at the usecase. See this example from rust-chat. https://github.com/nbaksalyar/rust-chat/blob/master/src/main.rs – nielsle Dec 06 '15 at 12:22
  • i have tried to refer that echo server example. but i get problem when i tried to access event of SERVER B (TcpStream). – M Harry Dec 09 '15 at 13:14

0 Answers0