René's URL Explorer Experiment


Title: socket.connect - support custom family value · Issue #92658 · python/cpython · GitHub

Open Graph Title: socket.connect - support custom family value · Issue #92658 · python/cpython

X Title: socket.connect - support custom family value · Issue #92658 · python/cpython

Description: Feature or enhancement Currently socket.connect() accepts a wide range of values when connecting to a socket with the code in socketmodule.c transforming it based on the family the socket was created with. Unfortunately there is a check ...

Open Graph Description: Feature or enhancement Currently socket.connect() accepts a wide range of values when connecting to a socket with the code in socketmodule.c transforming it based on the family the socket was creat...

X Description: Feature or enhancement Currently socket.connect() accepts a wide range of values when connecting to a socket with the code in socketmodule.c transforming it based on the family the socket was creat...

Opengraph URL: https://github.com/python/cpython/issues/92658

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"socket.connect - support custom family value","articleBody":"**Feature or enhancement**\r\n\r\nCurrently `socket.connect()` accepts a wide range of values when connecting to a socket with the code in `socketmodule.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 unrecognized https://github.com/python/cpython/blob/9d85aba9e245c1a0f6d1879f8bc6c260cb4eb721/Modules/socketmodule.c#L2530-L2534.\r\n\r\nMy 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.\r\n\r\n**Pitch**\r\n\r\nThe 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.\r\n\r\n Currently I am using the following to work around this restriction by using ctypes to call the C API directly and using the fileno:\r\n\r\n```python\r\nimport ctypes\r\nimport socket\r\nimport uuid\r\n\r\nHV_GUID_VM_SESSION_SERVICE_ID = uuid.UUID(\"999e53d4-3d5c-4c3e-8779-bed06ec056e1\")\r\nHV_GUID_VM_SESSION_SERVICE_ID_2 = uuid.UUID(\"a5201c21-2770-4c11-a68e-f182edb29220\")\r\nAF_HYPERV = 34\r\nHV_PROTOCOL_RAW = 1\r\n\r\n# This is the GUID of the Win VM to connect to\r\nvm_id = uuid.UUID(\"...\")\r\n\r\nwin32sock = ctypes.WinDLL(\"Ws2_32.dll\")\r\n\r\nraw_sock = win32sock.socket(AF_HYPERV, socket.SOCK_STREAM, HV_PROTOCOL_RAW)\r\nif raw_sock == -1:\r\n    err = win32sock.WSAGetLastError()\r\n    raise ctypes.WinError(code=err)\r\n\r\ntry:\r\n    sock_addr = b\"\\x22\\x00\\x00\\x00\" + vm_id.bytes_le + HV_GUID_VM_SESSION_SERVICE_ID.bytes_le\r\n    res = win32sock.connect(raw_sock, sock_addr, len(sock_addr))\r\n    if res:\r\n        err = win32sock.WSAGetLastError()\r\n        raise ctypes.WinError(code=err)\r\n\r\n    sock = socket.socket(fileno=raw_sock)\r\nexcept:\r\n    win32sock.closesocket(raw_sock)\r\n    raise\r\n\r\n...\r\n\r\nsock.close()\r\n```\r\n\r\nIt would be good to be able to do this instead\r\n\r\n```python\r\nimport socket\r\n\r\nsock = socket.socket(AF_HYPERV, socket.SOCK_STREAM, HV_PROTOCOL_RAW)\r\nsock_addr = b\"\\x22\\x00\\x00\\x00\" + vm_id.bytes_le + HV_GUID_VM_SESSION_SERVICE_ID.bytes_le\r\nsock.connect(sock_addr)\r\n\r\n...\r\n\r\nsock.close()\r\n```\r\n\r\nCurrently that fails due to the hardcoded check against unknown families\r\n\r\n```python\r\nTraceback (most recent call last):\r\n  File \"\u003cstdin>\", line 1, in \u003cmodule>\r\nOSError: connect(): bad family\r\n```\r\n\r\nAnother 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.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-105267\n* gh-105398\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/jborean93","@type":"Person","name":"jborean93"},"datePublished":"2022-05-11T06:02:25Z","url":"https://github.com/python/cpython/issues/92658"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:31a9b9cf-8a6e-ffaf-8ae4-811ca9d4be78
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD310:278022:DD37F4:120D070:6AFFF9AF
html-safe-noncea72ef786c4d4f29b8562f2166809de11a92845fd559040c6f7b02ac7135e09d2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzEwOjI3ODAyMjpERDM3RjQ6MTIwRDA3MDo2QUZGRjlBRiIsInZpc2l0b3JfaWQiOiI2MTI0MTA5NDQ3Mjg0MzkwMzE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacdf4e83c6fa7991c77d99c541c4a3f70397d7eea414485424c752bef53ab68108
hovercard-subject-tagissue:1232054974
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/92658/issue_layout
twitter:imagehttps://opengraph.githubassets.com/048b661604d2a1e3aeeea4cf5b3888a386726a06f14008f829eb46dcd7d0df7e/python/cpython/issues/92658
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/048b661604d2a1e3aeeea4cf5b3888a386726a06f14008f829eb46dcd7d0df7e/python/cpython/issues/92658
og:image:altFeature or enhancement Currently socket.connect() accepts a wide range of values when connecting to a socket with the code in socketmodule.c transforming it based on the family the socket was creat...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejborean93
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/92658#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F92658
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F92658
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/92658
Reloadhttps://github.com/python/cpython/issues/92658
Reloadhttps://github.com/python/cpython/issues/92658
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/92658
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/92658
#92755https://github.com/python/cpython/pull/92755
socket.connect - support custom family valuehttps://github.com/python/cpython/issues/92658#top
#92755https://github.com/python/cpython/pull/92755
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/jborean93
jborean93https://github.com/jborean93
on May 11, 2022https://github.com/python/cpython/issues/92658#issue-1232054974
cpython/Modules/socketmodule.chttps://github.com/python/cpython/blob/9d85aba9e245c1a0f6d1879f8bc6c260cb4eb721/Modules/socketmodule.c#L2530-L2534
9d85abahttps://github.com/python/cpython/commit/9d85aba9e245c1a0f6d1879f8bc6c260cb4eb721
gh-92658: Fix typo in docs and tests for HV_GUID_PARENT #105267https://github.com/python/cpython/pull/105267
[3.12] gh-92658: Fix typo in docs and tests for HV_GUID_PARENT (GH-105267) #105398https://github.com/python/cpython/pull/105398
jborean93https://github.com/jborean93
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
on May 11, 2022https://github.com/python/cpython/issues/92658#event-6587114183
https://github.com/ronaldoussoren
ronaldoussorenhttps://github.com/ronaldoussoren
on May 11, 2022https://github.com/python/cpython/issues/92658#issuecomment-1123564884
https://github.com/jborean93
jborean93https://github.com/jborean93
on May 11, 2022https://github.com/python/cpython/issues/92658#issuecomment-1123599990
ronaldoussorenhttps://github.com/ronaldoussoren
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on May 12, 2022https://github.com/python/cpython/issues/92658#event-6597369165
https://github.com/jborean93
jborean93https://github.com/jborean93
on May 13, 2022https://github.com/python/cpython/issues/92658#issuecomment-1125562134
#92755https://github.com/python/cpython/pull/92755
zoobahttps://github.com/zooba
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#92755https://github.com/python/cpython/pull/92755
on May 24, 2022https://github.com/python/cpython/issues/92658#event-6672196603
zoobahttps://github.com/zooba
on May 24, 2022https://github.com/python/cpython/issues/92658#event-6672197383
gh-92658: Add Hyper-V socket support (GH-92755)https://github.com/python/cpython/commit/fbd11f3edd6d2034774d802e048261e613ffcbf5
gh-92658https://github.com/python/cpython/issues/92658
GH-92755https://github.com/python/cpython/pull/92755
fbd11f3https://github.com/python/cpython/commit/fbd11f3edd6d2034774d802e048261e613ffcbf5
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on May 24, 2022https://github.com/python/cpython/issues/92658#issuecomment-1136543923
https://github.com/jborean93
jborean93https://github.com/jborean93
on May 25, 2022https://github.com/python/cpython/issues/92658#issuecomment-1136554369
vstinnerhttps://github.com/vstinner
on May 25, 2022https://github.com/python/cpython/issues/92658#event-6673900974
gh-92658: AF_HYPERV is only supported on Windows (#93192)https://github.com/python/cpython/commit/08e4e887f2d4650972272b2f4441485f3e1e9aab
gh-92658https://github.com/python/cpython/issues/92658
#93192https://github.com/python/cpython/pull/93192
08e4e88https://github.com/python/cpython/commit/08e4e887f2d4650972272b2f4441485f3e1e9aab
sobolevnhttps://github.com/sobolevn
on Jun 3, 2023https://github.com/python/cpython/issues/92658#event-9420459846
pythongh-92658: Fix typo in docs and tests for `HV_GUID_PARENT`https://github.com/sobolevn/cpython/commit/759e077d5609dddc35289915a0ae913bf6791ebb
pythongh-92658https://github.com/python/cpython/issues/92658
759e077https://github.com/sobolevn/cpython/commit/759e077d5609dddc35289915a0ae913bf6791ebb
zoobahttps://github.com/zooba
on Jun 6, 2023https://github.com/python/cpython/issues/92658#event-9448276662
gh-92658: Fix typo in docs and tests for `HV_GUID_PARENT` (GH-105267)https://github.com/python/cpython/commit/3907de12b57b14f674cdcc80ae64350a23af53a0
gh-92658https://github.com/python/cpython/issues/92658
GH-105267https://github.com/python/cpython/pull/105267
3907de1https://github.com/python/cpython/commit/3907de12b57b14f674cdcc80ae64350a23af53a0
miss-islingtonhttps://github.com/miss-islington
on Jun 6, 2023https://github.com/python/cpython/issues/92658#event-9448277565
pythongh-92658: Fix typo in docs and tests for `HV_GUID_PARENT` (pyth…https://github.com/miss-islington/cpython/commit/db6cd840117097e6fe0f9054a2faace5124e4590
pythongh-92658https://github.com/python/cpython/issues/92658
pyth…https://github.com/python/cpython/pull/105267
db6cd84https://github.com/miss-islington/cpython/commit/db6cd840117097e6fe0f9054a2faace5124e4590
zoobahttps://github.com/zooba
on Jun 6, 2023https://github.com/python/cpython/issues/92658#event-9449979457
gh-92658: Fix typo in docs and tests for `HV_GUID_PARENT` (GH-105267)https://github.com/python/cpython/commit/e33add429f8f16340b4c186501bb1e436e66b4cc
gh-92658https://github.com/python/cpython/issues/92658
GH-105267https://github.com/python/cpython/pull/105267
e33add4https://github.com/python/cpython/commit/e33add429f8f16340b4c186501bb1e436e66b4cc
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/92658
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/92658
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.