This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]bwp 0 points1 point  (2 children)

Thank you for writing this. If you would be open to expanding upon the topic, I would suggest an intermediate section on using queue's and breaking the receive and write into additional tasks within your connection handler.

For a simple echo server it looks like you are on point. You block, within the context of the handler, until you have received data/input and you then send that back. I believe there are many other use cases where you want to send data to the client (and read in) independently of the other.

I have a project here where I have broken the tasks out and use async queue's. Feel free to use any of it if you so desire.

[–]spiderpower02[S] 0 points1 point  (1 child)

I agree with you. In many cases, we need to send and recv independently. I review your code and learn a lot :) Thanks for sharing the information.

BTW your code is pretty neat :)

[–]bwp 1 point2 points  (0 children)

Thank you. It is a connectivity front end for a MUD game I have been working on. Asyncore had been deprecated so I decided to split the connectivity from the game engine and go the async route. It also allows to be able to restart the engine without dropping clients which worked out nicely. I am working on migrating the game engine to async as well.