Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:08:30+00:00 2026-06-11T22:08:30+00:00

I am trying to UDP broadcast from a Python program to two LabView programs.

  • 0

I am trying to UDP broadcast from a Python program to two LabView programs. I cannot seem to get the broadcast to send and I am not sure where my socket initialization is wrong, broadcasting seems simple enough?? As far as I can see, there is no data being received by the other PC’s. Also, I will need this program to receive data back from the other PC’s in the future. It seems like that shouldn’t complicate things but every step of the way has been complicated for me!

Background: I have zero software experience, this is just something I was assigned at work. Any help is appreciated. Code is below. Python 2.7.

from threading import Thread  
import time  
from socket import *  

cs = socket(AF_INET, SOCK_DGRAM)  
cs.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)  
cs.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)  
cs.connect(('<broadcast>', 5455)) 


while 1:
    cmd = int(raw_input('send: '))
    if (cmd == 1):
        cs.send('1')
    time.sleep(1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:08:31+00:00Added an answer on June 11, 2026 at 10:08 pm

    You do not need to connect() to a UDP socket, instead:

    cs.sendto(data, ('255.255.255.255', 5455))
    

    EDIT: This seems to work for me:

    from socket import *
    cs = socket(AF_INET, SOCK_DGRAM)
    cs.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    cs.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
    cs.sendto('This is a test', ('255.255.255.255', 54545))
    

    On another machine I ran tcpdump:

    tcpdump -i eth1 port 54545 -XX
    listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
    
    14:04:01.797259 IP 10.22.4.45.33749 > 255.255.255.255.54545: UDP, length 14
    0x0000:  ffff ffff ffff f0de f1c4 8aa6 0800 4500  ..............E.
    0x0010:  002a 0000 4000 4011 2c81 0a16 042d ffff  .*..@.@.,....-..
    0x0020:  ffff 83d5 d511 0016 fe38 5468 6973 2069  .........8This.i
    0x0030:  7320 6120 7465 7374 0000 0000            s.a.test....
    

    You can see the text in the payload. As well as the broadcast Ethernet and IP dst addrs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send a HTTP GET request with UDP (since the reply from
I am trying to read the UDP packages in python, which were sent from
For a project, I'm trying to send UDP packets from Linux kernel-space. I'm currently
I'm trying to get log4net to log via udp to chainsaw but its not
I'm trying write a java program to send live microphone data over UDP, then
I'm trying to send a UDP broadcast on IP address 255.255.255.255 for device discovery
I am trying to send UDP datagrams from a UdpClient on Windows XP to
I am trying to learn udp sockets etc.... I created two programs server and
Im trying to continuously send small UDP-packets (8 byte) as fast as possible from
I'm trying to write a program that reads broadcasted UDP datagrams in linux.I'm a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.