asynchronous icon indicating copy to clipboard operation
asynchronous copied to clipboard

Unix sockets not working

Open MoritzMaxeiner opened this issue 9 years ago • 3 comments

The README suggests that sockets have been fully implemented. When I try to use Unix sockets via openUnixConnection, however, it will crash either here (release mode) or here (debug mode). I know that libasync has no official support for Unix socket yet, but I assumed that you were hijacking libasync' tcp functionality for unix sockets?

MoritzMaxeiner avatar May 31 '16 22:05 MoritzMaxeiner

I think that as long as libasync is used, the fix in libasync in necessary (the two functions are called internally by libasync). Actually, it is not necessary to add full support for UNIX sockets in libasync, just adding AF_UNIX in the two switches will suffice.

dcarp avatar Jun 04 '16 21:06 dcarp

Well, AsyncTCPConnection is specifically for TCP, not for general (stateful) sockets. While it may be true that it can be hacked to accept preinitialised unix domain sockets, I consider that to be horrible from an API perspective. Imagine someone trying to set tcp options on an AsyncTCPConnection that has a unix domain socket below. Or someone thinking they can use unix domain sockets on Windows, since - hey - they are hidden behind AsyncTCPConnection and that exists on Windows. The entire point of abstraction - imho - is to make things easier to understand&use But I digress.

In any case, I've already done the legwork of cleanly implementing unix domain sockets for libasync (on top of its shiny new generic AsyncEvent interface) and I am hopeful of it being merged into upstream. From asynchronous' perspective, it would then more or less just need to replace new AsyncTCPConnection with new AsyncUDSConnection for setup and TCPEvent with EventCode in the handler.

MoritzMaxeiner avatar Jun 04 '16 21:06 MoritzMaxeiner

Extending sockAddrLen() and toAddressString() in AsyncTCPConnection to support UNIX sockeis in libasync is pretty harmless. The API will still not support them. Anyhow, it is great that you implemented the "right solution". When the UNIX sockets will be available in libasync, I will update the dependency version in asynchronous.

dcarp avatar Jun 05 '16 00:06 dcarp