poco icon indicating copy to clipboard operation
poco copied to clipboard

Make socket non-blocking in socket acceptor

Open JackyWoo opened this issue 2 years ago • 3 comments

Make socket non-blocking in socket acceptor

JackyWoo avatar Aug 07 '22 06:08 JackyWoo

I don't think we should do this - users who want non-blocking sockets can (and probably already do) make them so. Perhaps it does make sense to be non-blocking by default, but with this change we'd only be breaking the existing user applications that actually want blocking sockets.

aleks-f avatar Aug 07 '22 19:08 aleks-f

hi aleks-f, thanks for response, should we add constructor param to SocketAcceptor? And perhaps we could add possability to set some commonly used socket options in SocketAcceptor.

JackyWoo avatar Aug 08 '22 12:08 JackyWoo

We could do that, but it seems unnecessary because the end user has access to the socket and can modify its behavior any way they want in the handler.

A more worthy acceptor improvement, in my opinion, would be to somehow (variadic template parameters? enable_if?) allow the customer's service handler to have additional constructor arguments:

https://github.com/pocoproject/poco/blob/be19dc4a2f30eb97cc9bdd7551460db11cc27353/Net/include/Poco/Net/SocketAcceptor.h#L160

Right now any service handler property or (co)ownership of an external object can not be set at the handler construction time.

aleks-f avatar Aug 09 '22 07:08 aleks-f

@aleks-f ok, I will close this pr and I posted another pr #3741 try to add support of additional constructor parameters.

JackyWoo avatar Aug 11 '22 15:08 JackyWoo