René's URL Explorer Experiment


Title: Can't receive replies to multicast UDP packets · Issue #480 · python/asyncio · GitHub

Open Graph Title: Can't receive replies to multicast UDP packets · Issue #480 · python/asyncio

X Title: Can't receive replies to multicast UDP packets · Issue #480 · python/asyncio

Description: It doesn't appear to be possible to receive replies to multicast UDP messages. Server-side multicast does work, but only with a bit of extra config. Given the following (working) server code, adapted from the UDP Echo example: import asy...

Open Graph Description: It doesn't appear to be possible to receive replies to multicast UDP messages. Server-side multicast does work, but only with a bit of extra config. Given the following (working) server code, adapt...

X Description: It doesn't appear to be possible to receive replies to multicast UDP messages. Server-side multicast does work, but only with a bit of extra config. Given the following (working) server code, a...

Opengraph URL: https://github.com/python/asyncio/issues/480

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't receive replies to multicast UDP packets","articleBody":"It doesn't appear to be possible to receive replies to multicast UDP messages.  Server-side multicast does work, but only with a bit of extra config.\r\n\r\nGiven the following (working) server code, adapted from the UDP Echo example:\r\n\r\n```\r\nimport asyncio\r\nimport logging\r\nimport socket\r\nimport struct\r\n\r\nBROADCAST_PORT = 1910\r\nBROADCAST_ADDR = \"239.255.255.250\"\r\n\r\n\r\nclass MulticastServerProtocol:\r\n\r\n    def connection_made(self, transport):\r\n        self.transport = transport\r\n\r\n\r\n    def datagram_received(self, data, addr):\r\n        print('Received {!r} from {!r}'.format(data, addr))\r\n        data = \"I received {!r}\".format(data).encode(\"ascii\")\r\n        print('Send {!r} to {!r}'.format(data, addr))\r\n        self.transport.sendto(data, addr)\r\n\r\n\r\n\r\nloop = asyncio.get_event_loop()\r\nloop.set_debug(True)\r\nlogging.basicConfig(level=logging.DEBUG)\r\n\r\n\r\nsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\r\nsock.bind(('', BROADCAST_PORT))\r\ngroup = socket.inet_aton(BROADCAST_ADDR)\r\nmreq = struct.pack('4sL', group, socket.INADDR_ANY)\r\nsock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)\r\nsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\r\nsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)\r\n\r\nlisten = loop.create_datagram_endpoint(\r\n    MulticastServerProtocol,\r\n    sock=sock,\r\n)\r\ntransport, protocol = loop.run_until_complete(listen)\r\n\r\nloop.run_forever()\r\nloop.close()\r\n```\r\n\r\n...the following _non-asyncio_ client code sends a broadcast packet and correctly receives the responses:\r\n\r\n```\r\nimport socket\r\nimport struct\r\nimport sys\r\n\r\nBROADCAST_PORT = 1910\r\nBROADCAST_ADDR = \"239.255.255.250\"\r\n\r\n\r\nsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\r\nsock.settimeout(3)\r\nttl = struct.pack('b', 1)\r\nsock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)\r\n\r\ntry:\r\n    sent = sock.sendto(\r\n        sys.argv[1].encode(\"ascii\"),\r\n        (BROADCAST_ADDR, BROADCAST_PORT)\r\n    )\r\n\r\n    while True:\r\n        try:\r\n            data, server = sock.recvfrom(1024)\r\n        except socket.timeout:\r\n            break\r\n        else:\r\n            print(\"Reply from {}: {!r}\".format(server, data))\r\n\r\nfinally:\r\n    sock.close()\r\n```\r\n\r\nHowever, the following code, which I'm pretty sure is the asyncio equivalent, sends out the mutlicast packet correctly but never receives a response:\r\n\r\n```\r\nimport asyncio\r\nimport socket\r\nimport struct\r\nimport sys\r\n\r\nBROADCAST_PORT = 1910\r\nBROADCAST_ADDR = \"239.255.255.250\"\r\n\r\n\r\n\r\nclass DiscoveryClientProtocol:\r\n    def __init__(self, loop):\r\n        self.loop = loop\r\n        self.transport = None\r\n\r\n    def connection_made(self, transport):\r\n        self.transport = transport\r\n        sock = self.transport.get_extra_info('socket')\r\n        sock.settimeout(3)\r\n        ttl = struct.pack('b', 1)\r\n        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)\r\n\r\n        self.transport.sendto(sys.argv[1].encode(\"ascii\"))\r\n\r\n    def datagram_received(self, data, addr):\r\n        print(\"Reply from {}: {!r}\".format(addr, data))\r\n        # Don't close the socket as we might get multiple responses.\r\n\r\n    def error_received(self, exc):\r\n        print('Error received:', exc)\r\n\r\n    def connection_lost(self, exc):\r\n        print(\"Socket closed, stop the event loop\")\r\n        self.loop.stop()\r\n\r\n\r\nloop = asyncio.get_event_loop()\r\nconnect = loop.create_datagram_endpoint(\r\n    lambda: DiscoveryClientProtocol(loop),\r\n    remote_addr=(BROADCAST_ADDR, BROADCAST_PORT),\r\n)\r\ntransport, protocol = loop.run_until_complete(connect)\r\nloop.run_forever()\r\ntransport.close()\r\nloop.close()\r\n\r\n```","author":{"url":"https://github.com/gpjt","@type":"Person","name":"gpjt"},"datePublished":"2017-01-04T16:07:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/480/asyncio/issues/480"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:04959fa4-354e-ad98-c788-19a731976e82
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCC0:35FE44:E4624:13C5B2:696E257C
html-safe-noncea59f568fb74bff9d1bfa7855c4ca919880f14ed31e788721cc672aade8568bb8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0MwOjM1RkU0NDpFNDYyNDoxM0M1QjI6Njk2RTI1N0MiLCJ2aXNpdG9yX2lkIjoiNjQzNDk2NzUxMDcxNjM5MjgyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac0d11073e6e0c7680f164397469109d8a59b58182faf71bbc3442517bbd4d3166
hovercard-subject-tagissue:198743983
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/asyncio/480/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a44acf48f4cb22e60b50a43bfbe7734867b50a07fefc780cc81aa0a76c27c309/python/asyncio/issues/480
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a44acf48f4cb22e60b50a43bfbe7734867b50a07fefc780cc81aa0a76c27c309/python/asyncio/issues/480
og:image:altIt doesn't appear to be possible to receive replies to multicast UDP messages. Server-side multicast does work, but only with a bit of extra config. Given the following (working) server code, adapt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegpjt
hostnamegithub.com
expected-hostnamegithub.com
None2fbe8cba5e260284c10af515699ff9bb2d6ace05ab6c2e2e585b71d93b2812c3
turbo-cache-controlno-preview
go-importgithub.com/python/asyncio git https://github.com/python/asyncio.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id33739295
octolytics-dimension-repository_nwopython/asyncio
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33739295
octolytics-dimension-repository_network_root_nwopython/asyncio
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
release7fb3bc5c995a876085291706b75cf9b08900c338
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python/asyncio/issues/480#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fasyncio%2Fissues%2F480
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fasyncio%2Fissues%2F480
Sign up https://patch-diff.githubusercontent.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%2Fasyncio
Reloadhttps://patch-diff.githubusercontent.com/python/asyncio/issues/480
Reloadhttps://patch-diff.githubusercontent.com/python/asyncio/issues/480
Reloadhttps://patch-diff.githubusercontent.com/python/asyncio/issues/480
python https://patch-diff.githubusercontent.com/python
asynciohttps://patch-diff.githubusercontent.com/python/asyncio
Please reload this pagehttps://patch-diff.githubusercontent.com/python/asyncio/issues/480
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fasyncio
Fork 185 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fasyncio
Star 1.1k https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fasyncio
Code https://patch-diff.githubusercontent.com/python/asyncio
Issues 76 https://patch-diff.githubusercontent.com/python/asyncio/issues
Pull requests 10 https://patch-diff.githubusercontent.com/python/asyncio/pulls
Actions https://patch-diff.githubusercontent.com/python/asyncio/actions
Projects 0 https://patch-diff.githubusercontent.com/python/asyncio/projects
Wiki https://patch-diff.githubusercontent.com/python/asyncio/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/python/asyncio/security
Please reload this pagehttps://patch-diff.githubusercontent.com/python/asyncio/issues/480
Insights https://patch-diff.githubusercontent.com/python/asyncio/pulse
Code https://patch-diff.githubusercontent.com/python/asyncio
Issues https://patch-diff.githubusercontent.com/python/asyncio/issues
Pull requests https://patch-diff.githubusercontent.com/python/asyncio/pulls
Actions https://patch-diff.githubusercontent.com/python/asyncio/actions
Projects https://patch-diff.githubusercontent.com/python/asyncio/projects
Wiki https://patch-diff.githubusercontent.com/python/asyncio/wiki
Security https://patch-diff.githubusercontent.com/python/asyncio/security
Insights https://patch-diff.githubusercontent.com/python/asyncio/pulse
Can't receive replies to multicast UDP packetshttps://patch-diff.githubusercontent.com/python/asyncio/issues/480#top
https://github.com/gpjt
https://github.com/gpjt
gpjthttps://github.com/gpjt
on Jan 4, 2017https://github.com/python/asyncio/issues/480#issue-198743983
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.