-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UNIXSocket does not work when socket type is DGRAM #3214
Comments
Good catch! UNIXSocket was only tested with STREAM, not DGRAM. I looked at Ruby and it doesn't provide any nicety, and instead relies on manual Socket instantiation (see this example). Maybe UNIXSoket#initialize could take an optional |
I've made more research recently, on how to implement this, and ended up realizing that we can't unify all in In the same way that :
We will need to have something like I currently don't know how to handle a socket pair from UNIXSocket#pair. Do you agree ? Should I try and implement this ? |
I'd like to rework how sockets are currently implemented, to something a bit more Ruby-like. I'd like a generic Socket class, with all the methods to bind, listen, accept, setsockopts, and so on. That would allow to create any kind of socket, like RAW sockets, have more control over sockets to build custom servers, for example DGRAM UNIX sockets, setting the Special classes, that is |
Hi !
I'm trying to make a wpa_supplicant front end in pure-crystal, and I need to connect to the server using Unix Socket with the DGRAM (datagram) socket type.
The UNIXSocket class provides a good abstraction, but there are some specificity when using DGRAM that are not handled :
This code will hang forever on
client.gets(4096)
. It's not the server fault, I tested with wpa_supplicant server..Found the answer on stackoverflow
The reason is that the socket is not properly configured when the DGRAM socket type is used :
Another exemple is in wpa_cli source (a wpa_supplicant front end) at this line 93, where it creates the socket that will connect to the server :
socket
: Create the socketbind
: Give the socket a name (<== this is the missing part)connect
: Connect to the serverI've made & push a dirty fix here
I don't really know if my fix is complete and how to implement this in crystal stdlib (naming/logic/..)
@asterite @ysbaddaden : You worked on this, maybe you can help ?
The text was updated successfully, but these errors were encountered: