<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 中接收广播数据包

        时间:2023-09-28
          • <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 中接收广播数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Python 中进行位域操作的最佳方法是什么? 下一篇:如何通过 OpenCV 处理 VLC UDP 流

                  相关文章

                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>

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