tmds / Tmds.LinuxAsync

MIT License
25 stars 3 forks source link

Add option to host an "echo" server #82

Closed antonfirsov closed 4 years ago

antonfirsov commented 4 years ago

Resolves #73.

Dumb as hell, can't handle concurrent connections.

antonfirsov commented 4 years ago

@tmds does it look better now? any further suggestions?

antonfirsov commented 4 years ago

@tmds I kept my handling logic sequential ("echo-serverish"). Based on your comments, it looks like you want to enable handling connections in parallel, right? Makes sense if we want to test various scheduling modes.

tmds commented 4 years ago

Based on your comments, it looks like you want to enable handling connections in parallel, right?

Yes. And we're in full control of how many epoll threads there are and how many clients connect. So we can still connect a single client and run that on a single epoll thread.

I kept my handling logic sequential ("echo-serverish").

I guess this is about my comment to refactor ClientConnectionHandler? The suggested refactoring is sequential:

When a send is done, start a receive:

_sendArgs.Completed += (s, a) => ReceiveRequest();

When a request is complete, send a response:

        if (RequestComplete(...))
        {
            _bytesReceived = 0;
            SendResponse();
        }

ManualResetEventSlim will give some overhead, we don't need it.

antonfirsov commented 4 years ago

@tmds just pushed your suggestions, works smoothly on my machine.

tmds commented 4 years ago

LGTM! Thanks!