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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:29:20+00:00 2026-05-12T10:29:20+00:00

I have some networking code which connects to a multicast address but disconnects after

  • 0

I have some networking code which connects to a multicast address but disconnects after a few seconds. Can anyone figure out what’s wrong with this code?

String Target_IP = "224.1.2.3"; 
int Target_Port = 31337;

IPEndPoint LocalEP = new IPEndPoint(IPAddress.Any, Target_Port);
IPEndPoint RemoteEP = new IPEndPoint(IPAddress.Parse(Target_IP), Target_Port); 

using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
{
    s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
    //s.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.NoDelay, 1);
    //s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
    s.Bind(LocalEP);
    s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 0);
    s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(Target_IP)));
    s.Connect(RemoteEP);

    // TODO
}

After the Connect() function is called it reports as connected, but wait a second or two and it is disconnected. Am I binding to the wrong ports or something? Every online tutorial seems to do it a different way.

  • 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-12T10:29:21+00:00Added an answer on May 12, 2026 at 10:29 am

    Since you are using UDP you cannot “connect” to the remote target. The Connect method on connectionless protocols does not connect as such but acts as a filter on what destintations it will accept packets from.

    When you say you disconnect after a few seconds how are you determining that? If you are checking th connected status on the socket you are doing the wrong thing. Instead you should just start receiving and the only way to tell that the remote socket “may” have dropped off is if you get a 0 byte packet or you get an ICMP response from it.

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

Sidebar

Related Questions

i have try some command like system(reboot) exec(reboot) and system(/ect/init.d/networking restart); but not happen
So I have a very weird problem. I am writing some code in VB.Net
I have a program that does some networking using Winsock, and one of our
I'm looking for some networking gurus to help me with a problem. I have
I have a Networking service that i want to use as a Service. It's
Earlier on I've implemented a custom C++ server from scratch, something which is nice
I'm sure this is a very common operation when doing any kind of network
I am using CorePlot to draw different graphs in my application. Then, I would
The goal is to implement a Gallery whose adapter returns ListViews (in other words,
I've not used Spring too much, so I might be missing something obvious. Anyway,

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.