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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:22:43+00:00 2026-05-23T13:22:43+00:00

I’m using a UdpClient at the server end and it is sending data to

  • 0

I’m using a UdpClient at the server end and it is sending data to the client end (more than one client).
Suddenly the client stops listening on the udp port and the server gets hit with an SocketException, either when calling endRecieve or beginRecieve.

To my understanding this is because of an “ICMP Destination Unreachable” and it’s just telling the server the port’s closed. That’s ok, but neither of the SocketExceptions tell me which endpoint it is from.

How can I know which endpoint is closed so the server stops sending to it and causing more SocketExceptions?

Or is there a way for Udpclient to stop throwing these SocketExceptions so I can make the clients timeout if they don’t respond after so and so seconds.

  • 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-23T13:22:44+00:00Added an answer on May 23, 2026 at 1:22 pm

    I’m dealing with the same issue myself so I’ll be interested to see if anyone comes up with a better solution, but for now I have a couple ideas:

    I have a comm wrapper class (let’s call it AsyncComm) around my sockets that is passed an exception handler delegate from its owner class when it’s constructed. The exception handler delegate takes arguments of an exception and a reference to the AsyncComm instance that threw it. I then put

    try
    {
       // Do stuff here
    {
    catch (Exception e)
    {
       CallExceptionHandlerDelegate(e, this);
    }
    

    in each of my async handler methods in AsyncComm so they can throw their exceptions up the chain. In my case, the exception handler uses the reference to the AsyncComm instance to call a method in the AsyncComm instance to tell it to reinitialize its socket. You can change that behavior to whatever you need to do to stop continuously getting SocketExceptions.

    Regarding determining the end point the exception came from, the only idea I have right now is parsing the end point from the end of the SocketException.Message string, but that seems like quite a kludge.

    Update: It is a kludge but it works. Parse code below, some of it taken from this question.

    private IPEndPoint parseEndPointFromString(string input)
    {
        // Matches 1-255.1-255.1-255.1-255:0-65535. I think.
        const string IPPortRegex = @"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)";
    
        Match match = Regex.Match(input, IPPortRegex);
    
        if (match.Success)
        {
            string IPPortString = match.Value;
    
            string[] ep = IPPortString.Split(':');
            if (ep.Length != 2) throw new FormatException("Invalid endpoint format");
            IPAddress ip;
            if (!IPAddress.TryParse(ep[0], out ip))
            {
                throw new FormatException("Invalid IP address");
            }
            int port;
            if (!int.TryParse(ep[1], out port))
            {
                throw new FormatException("Invalid port");
            }
            return new IPEndPoint(ip, port);
        }
        else
        {
            throw new FormatException("Invalid input string, regex could not find an IP:Port string.");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

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.