<legend id='QmaiE'><style id='QmaiE'><dir id='QmaiE'><q id='QmaiE'></q></dir></style></legend>
        • <bdo id='QmaiE'></bdo><ul id='QmaiE'></ul>
        <i id='QmaiE'><tr id='QmaiE'><dt id='QmaiE'><q id='QmaiE'><span id='QmaiE'><b id='QmaiE'><form id='QmaiE'><ins id='QmaiE'></ins><ul id='QmaiE'></ul><sub id='QmaiE'></sub></form><legend id='QmaiE'></legend><bdo id='QmaiE'><pre id='QmaiE'><center id='QmaiE'></center></pre></bdo></b><th id='QmaiE'></th></span></q></dt></tr></i><div id='QmaiE'><tfoot id='QmaiE'></tfoot><dl id='QmaiE'><fieldset id='QmaiE'></fieldset></dl></div>
      1. <tfoot id='QmaiE'></tfoot>

        <small id='QmaiE'></small><noframes id='QmaiE'>

        在 Python 中接收广播数据包

        Receiving Broadcast Packets in Python(在 Python 中接收广播数据包)
          • <tfoot id='R10LE'></tfoot>

              <legend id='R10LE'><style id='R10LE'><dir id='R10LE'><q id='R10LE'></q></dir></style></legend>

                <tbody id='R10LE'></tbody>
                <bdo id='R10LE'></bdo><ul id='R10LE'></ul>

              • <i id='R10LE'><tr id='R10LE'><dt id='R10LE'><q id='R10LE'><span id='R10LE'><b id='R10LE'><form id='R10LE'><ins id='R10LE'></ins><ul id='R10LE'></ul><sub id='R10LE'></sub></form><legend id='R10LE'></legend><bdo id='R10LE'><pre id='R10LE'><center id='R10LE'></center></pre></bdo></b><th id='R10LE'></th></span></q></dt></tr></i><div id='R10LE'><tfoot id='R10LE'></tfoot><dl id='R10LE'><fieldset id='R10LE'></fieldset></dl></div>
                1. <small id='R10LE'></small><noframes id='R10LE'>

                  本文介绍了在 Python 中接收广播数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下代码发送一个在子网中广播的 udp 数据包.

                  I have the following code which sends a udp packet that is broadcasted in the subnet.

                  from socket import *
                  s=socket(AF_INET, SOCK_DGRAM)
                  s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
                  s.sendto('this is testing',('255.255.255.255',12345))
                  

                  以下代码用于接收广播包.

                  The following code is for receiving the broadcast packet.

                  from socket import *
                  s=socket(AF_INET, SOCK_DGRAM)
                  s.bind(('172.30.102.141',12345))
                  m=s.recvfrom(1024)
                  print m[0]
                  

                  问题是它没有收到任何广播数据包.但是,它成功地接收到发送到该端口的正常 udp 数据包.

                  The problem is that its not receiving any broadcast packet. However, it is successfully receiving normal udp packets sent to that port.

                  我的机器显然正在接收广播数据包,我使用 netcat 对其进行了测试.

                  My machine was obviously receiving the broadcast packet, which I tested using netcat.

                  $ netcat -lu -p 12345                                             
                  this is testing^C
                  

                  那么,问题究竟出在哪里?

                  So, where exactly is the problem?

                  推荐答案

                  尝试绑定到默认地址:

                  s.bind(('',12345))
                  

                  这篇关于在 Python 中接收广播数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                2. <tfoot id='aKZUs'></tfoot>
                  1. <small id='aKZUs'></small><noframes id='aKZUs'>

                    <i id='aKZUs'><tr id='aKZUs'><dt id='aKZUs'><q id='aKZUs'><span id='aKZUs'><b id='aKZUs'><form id='aKZUs'><ins id='aKZUs'></ins><ul id='aKZUs'></ul><sub id='aKZUs'></sub></form><legend id='aKZUs'></legend><bdo id='aKZUs'><pre id='aKZUs'><center id='aKZUs'></center></pre></bdo></b><th id='aKZUs'></th></span></q></dt></tr></i><div id='aKZUs'><tfoot id='aKZUs'></tfoot><dl id='aKZUs'><fieldset id='aKZUs'></fieldset></dl></div>

                      <tbody id='aKZUs'></tbody>
                    <legend id='aKZUs'><style id='aKZUs'><dir id='aKZUs'><q id='aKZUs'></q></dir></style></legend>
                        • <bdo id='aKZUs'></bdo><ul id='aKZUs'></ul>