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 7539365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:21:45+00:00 2026-05-30T07:21:45+00:00

I am working on a broadcast beacon in C# that is supposed to broadcast

  • 0

I am working on a broadcast beacon in C# that is supposed to broadcast server information to all listening devices. The information sent will contain information like the URL of a WCF service, the namespace, a list of required arguments etc. What I have right now is a sender and receiver that can talk perfectly fine when they are on the same computer. However, once I put the sender on another computer than my receiver, the sender sends its message but my receiver never gets it. There are no exceptions being thrown, and the firewall is disabled on both machines.

http://codeidol.com/csharp/csharp-network/IP-Multicasting/What-Is-Broadcasting/ is where I got my code from.

Sender:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace UDPTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
            ProtocolType.Udp);
            sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
            IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, 9050);
            byte[] data = Encoding.ASCII.GetBytes("This is a test message");
            sock.SendTo(data, iep);
            sock.Close();
        }
    }
}

Receiver:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace UDPBroadcastReciever
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket sock = new Socket(AddressFamily.InterNetwork,
            SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint iep = new IPEndPoint(IPAddress.Any, 9050);
            sock.Bind(iep);
            EndPoint ep = (EndPoint)iep;
            Console.WriteLine("Ready to recieve");
            byte[] data = new byte[1024];
            int recv = sock.ReceiveFrom(data, ref ep);
            string stringData = Encoding.ASCII.GetString(data, 0, recv);
            Console.WriteLine("Received: {0} from: {1}", stringData, ep.ToString());
            sock.Close();
            Console.ReadLine();
        }
    }
}

Does anyone know of anything I am missing that would enable these two to talk on two different computers? They are on the same subnet (192.168.1.x)

Thanks
Nick Long

  • 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-05-30T07:21:46+00:00Added an answer on May 30, 2026 at 7:21 am

    You would probably be better off using multicast rather than broadcasting; broadcast packets are often dropped immediately by routers. Pick an IP address somewhere in the 239.0.0.0/24 block as your multicast address; this is reserved for organisation local messages, so just pick a number out of the air and stick with it.

    You need to have your sender send its packets to this address and have your receiver join the multicast group to receive them. To join the multicast group call this on your socket:

    sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
        new MulticastOption(theMulticastIp));
    

    There’s plenty more information about using multicast in C# here.

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

Sidebar

Related Questions

The server that Im working on (which is a Unix C multi-threaded non-block socket
I have designed this server to broadcast to all clients when it has to
I'm working on a Wake on LAN service that will run from a web
I'm working on a project that discovers/configures remote devices using UDP broadcasts. These devices
I am working on a LAN based solution with a server that has to
I'm working on an Android app that streams video to a remote server. My
I'm working on a client-server application written in C. I want to broadcast a
I have a boot complete broadcast receiver but it wasnt working as expected. Nor
Working with an undisclosed API, I found a function that can set the number
Working on game where plates will be falling from top to bottom. Some plates

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.