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

  • Home
  • SEARCH
  • 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 521069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:12:41+00:00 2026-05-13T08:12:41+00:00

I am new to Network Programming, and I am having a problem with some

  • 0

I am new to Network Programming, and I am having a problem with some code I’ve been testing as the basis of a LAN chat program.

Server Code:

public static void Main()
    {

        UdpClient publisher = new UdpClient("230.0.0.1", 8899);
        UdpClient subscriber = new UdpClient("230.0.0.2", 8800);
        IPAddress addr = IPAddress.Parse("230.0.0.1");
        subscriber.JoinMulticastGroup(addr);
        Console.WriteLine("Running chat program at 230.0.0.1:8899");


        while (true)
        {
            IPEndPoint ep = null;
            byte[] chats = subscriber.Receive(ref ep);
            string chatstring = Encoding.ASCII.GetString(chats);
            Console.WriteLine(chatstring);


            string msg = String.Format(chatstring);
            byte[] sdata = Encoding.ASCII.GetBytes(msg);
            publisher.Send(sdata, sdata.Length);



            System.Threading.Thread.Sleep(500);
        }
    }

And the client program:

static void Main(string[] args)
        {

            UdpClient subscriber = new UdpClient("230.0.0.1", 8899);

            IPAddress addr = IPAddress.Parse("230.0.0.1");
            subscriber.JoinMulticastGroup(addr);
            IPEndPoint ep = null;
            Thread SendChats = new Thread(Send);
            SendChats.Start();
            while (true)
            {
                byte[] receivedbytes = subscriber.Receive(ref ep);
                string receivedchats = Encoding.ASCII.GetString(receivedbytes);
                Console.WriteLine(receivedchats);
                Thread.Sleep(500);
            }
        }

        static void Send()
        {
            UdpClient publisher = new UdpClient("230.0.0.2", 8800);



            while (true)
            {
                string msg = Console.ReadLine();
                byte[] sdata = Encoding.ASCII.GetBytes(msg);
                publisher.Send(sdata, sdata.Length);
                Thread.Sleep(400);
            }

        }

By my figuring, the server program SHOULD be receiving data from the client, but alas, after a message is typed in and delivered, there is never anything getting through. Am I missing something?

  • 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-13T08:12:42+00:00Added an answer on May 13, 2026 at 8:12 am

    Is your subscriber joinging the wrong multicast in the server?

    UdpClient subscriber = new UdpClient("230.0.0.2", 8800);
    IPAddress addr = IPAddress.Parse("230.0.0.1");
    subscriber.JoinMulticastGroup(addr);
    

    Possibly should be:

    IPAddress addr = IPAddress.Parse("230.0.0.2");
    

    Also – have you got any routers/switches between the client/server as they will prevent multicast traffic unless specifically configured to do so.

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

Sidebar

Related Questions

I'm having a problem compiling my Java program: \Desktop\Java Programming\JFrameWithPanel.java:79: unexpected type required: variable
I am new to network programming, and have been learning this by writing small
I've made a simple dummy server/dummy client program using IOCP for some testing/profiling purpose.
I am new to python and network programming and I am having trouble with
So I'm having a problem making a new socket. I had this program that
I'm new to network programming. This is probably a stupid question, would it be
I'm new to network programming. I'm interested is it possible to establish network connection
I'm new to Java programming. I want to write simple Java network protocol. I
This topic resembles this thread I'm rather new to the topic of network programming,
I am new to socket programming, and I am having trouble understanding how select()

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.