dcarp / asynchronous

A D port of Python's asyncio library
Boost Software License 1.0
37 stars 6 forks source link

Unix sockets not working #8

Open MoritzMaxeiner opened 8 years ago

MoritzMaxeiner commented 8 years ago

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?

dcarp commented 8 years ago

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.

MoritzMaxeiner commented 8 years ago

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.

dcarp commented 8 years ago

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.