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

The Archive Base Latest Questions

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

Possible duplicates: UDP Response or Receiving a response through UDP I’ve been writing a

  • 0

Possible duplicates: UDP Response or Receiving a response through UDP

I’ve been writing a udp server-client setup over the last month and have a working server. This server is meant to be a communications program to retrieve data about the computer it’s hosted on that was requested by a remote client machine. The general idea is outlined below:

Client -> requests data -> Server ->
processes request -> sends response -> Client

And the client receives the data and does what it needs with that data.

I’m able to do everything in that outline, except where the client receives the packets and outputs them to my test console. If you want to see the UdpServer class, it’s simple, however just comment and I’ll post it up here in an edit.

Here’s how I’m receiving data (testing application):

executes: “test.exe <array index>”, e.g. “test.exe 4” -> executes against 204.229.219.35

public class Program {
    static void Main(String[] args) {
        string pre = "204.229.219";
        string[] servers = {
                               "31", "32", "33", "34", "35", "36",
                               "37", "38", "39", "40", "41", "42",
                               "88", "89"
                           };

        if (args.Length < 1)
        {
            Environment.Exit(1);
        }

        int idx = Int32.Parse(args[0]);

        Console.Title = "UDPSERVERTEST";

        UdpClient c = new UdpClient();

        Byte[] data = Encoding.ASCII.GetBytes("net user");

        IPEndPoint ep = new IPEndPoint(Dns.GetHostEntry(String.Format("{0}.{1}", pre, servers[idx])).AddressList[0], 8915);

        Console.WriteLine("\tQuerying: {0}", String.Format("{0}.{1}", pre, servers[idx]));

        c.Send(data, data.Length, ep);

        UdpState s = new UdpState();
        s.endPoint = new IPEndPoint(IPAddress.Any, 0);
        s.host = c;
        s.encoding = Encoding.ASCII;
        ReceiveCallback(s);

        Console.ReadKey(true);
    }

    private static void ReceiveCallback(UdpState s)
    {
        byte[] data = s.host.Receive(ref s.endPoint);
        Console.WriteLine("Data received from ({0}) -> {1}", s.endPoint.ToString(), s.encoding.GetString(data));
    }

    private static void callback(IAsyncResult ar)
    {
        UdpState s = (UdpState)ar.AsyncState;
        UdpClient u = s.host;
        IPEndPoint e = s.endPoint;

        byte[] data = u.EndReceive(ar, ref e);
    }
}

On either of my receiving methods, I get an error like the following:

An existing connection was forcibly
closed by the remote host

Thanks Stackoverflow!

  • 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-13T05:41:21+00:00Added an answer on May 13, 2026 at 5:41 am

    Can you verify that your text program is getting the “Receive Data” event to fire? If you aren’t getting anything to output to your test bench, there are two possible problems:

    1. The reply is being blocked by a firewall, but you make it sound like this works on other computers, so I will assume this isn’t the problem.
    2. Your data receive event isn’t firing. This could be because you don’t have your data port object configured correctly. Without more information about how you are doing this, that would be my best bet.

    What I would do is confirm that you are getting your event to fire first. If your data port object isn’t configured correctly, that can easily be your entire problem. If that is configured correctly, confirm that your server is actually sending a response. It may be that it is not sending and response and, therefore, your client isn’t receiving one.

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

Sidebar

Related Questions

Possible Duplicates: C++0X when? When will C++0x be finished? When will C++0x be released?
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on
Possible Duplicates: Iterate with for loop or while loop? Loops in C - for()
Possible Duplicates: Terminating a Python script Terminating a Python Program My question is how
Possible Duplicates: i = true and false in Ruby is true? What is the
Possible Duplicates: Deep Null checking, is there a better way? C# elegant way to
Possible Duplicates: const int = int const ? Const in C hi, I would
Possible Duplicates: Vector.erase(Iterator) causes bad memory access iterate vector, remove certain items as I
Possible Duplicates: Understanding “randomness” Fastest implementation of a true random number generator in C#
Possible Duplicates: Random numbers in C# Random number generator not working the way I

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.