Python send UDP packet

前端 未结 5 1768
盖世英雄少女心
盖世英雄少女心 2021-01-30 06:23

I am trying to write a program to send UDP packets, as in https://wiki.python.org/moin/UdpCommunication The code appears to be in Python 2:

import socket

UDP_I         


        
5条回答
  •  -上瘾入骨i
    2021-01-30 07:10

    Your code works as is for me. I'm verifying this by using netcat on Linux.

    Using netcat, I can do nc -ul 127.0.0.1 5005 which will listen for packets at:

    • IP: 127.0.0.1
    • Port: 5005
    • Protocol: UDP

    That being said, here's the output that I see when I run your script, while having netcat running.

    [9:34am][wlynch@watermelon ~] nc -ul 127.0.0.1 5005
    Hello, World!
    

提交回复
热议问题