-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
socket.connect - support custom family value #92658
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
Comments
It would IMHO be better to add explicit support for this new address family. |
I agree, especially from a UX perspective but would it also be nice if it supported arbitrary bytes in the cases when Python does not support the family for other protocols, now and in the future? |
I've added a PR that adds explicit support for the new address family. I'm not too experienced on the C side so any pointers or comments would be greatly appreciated #92755. |
I don't think that it's a good idea. Each protocol is different and requires special code. |
Fair enough, I mostly only desired it for the Hyper V stuff and was mindful if I came across another family I would have the same problem but that makes sense. |
Only build the AF_HYPERV support on Windows for the _socket extension. FreeBSD defines the AF_HYPERV macro but doesn't have the SOCKADDR_HV type.
…onGH-105267) (cherry picked from commit 3907de1) Co-authored-by: Nikita Sobolev <[email protected]>
(cherry picked from commit 3907de1) Co-authored-by: Nikita Sobolev <[email protected]>
Feature or enhancement
Currently
socket.connect()
accepts a wide range of values when connecting to a socket with the code insocketmodule.c
transforming it based on the family the socket was created with. Unfortunately there is a check that fails the connection if the family is unrecognizedcpython/Modules/socketmodule.c
Lines 2530 to 2534 in 9d85aba
My proposal is to allow a caller to bypass this check if passing in a raw byte value to be used as the addr info on the native call.
Pitch
The reason why I am hoping for this feature is to support clients connecting to a Hyper-V socket. This uses the
AF_HYPERV
family which isn't known to Python so any attempts to connect to it won't work.Currently I am using the following to work around this restriction by using ctypes to call the C API directly and using the fileno:
It would be good to be able to do this instead
Currently that fails due to the hardcoded check against unknown families
Another option is to add support for
AF_HYPERV
on Windows and support a tuple of (vm_id, service_id) and have Python create the struct. This could be done as a separate feature request potentially.Linked PRs
HV_GUID_PARENT
#105267HV_GUID_PARENT
(GH-105267) #105398The text was updated successfully, but these errors were encountered: