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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:44:59+00:00 2026-06-10T13:44:59+00:00

I was told that UDP was connectionless meaning that you could not be sure

  • 0

I was told that UDP was connectionless meaning that you could not be sure if the packages would reach the destination.

Why when doing:

var dataToSend = new byte[]{1};
UdpClient client = new UdpClient();
client.Send(dataToSend,1,"192.168.0.45", 1234);

the variable LocalEndpoint initializes:

enter image description here

Correct me if I am wrong. I believe that the variable LocalEndPoint was initialized by the router. The reason why I believe that is because every time the server (192.168.0.45) receives data and then replies, I see that data is being send through the port 62446 on the reply.

So my question is if I am using the udp protocol why am I getting a response from the router? If I am getting a response from the router then that is not UDP or perhaps I have a wrong understanding of udp. I dont think the port number get’s randomly picked. If I have had configure the router to do port forwarding on port 62446 to some other computer then my program will not have had worked.


here is the client code:

string ipOfServer = "192.168.0.45";
int portServerIsListeningOn = 1234;

// send data to server
Socket sending_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint sending_end_point = new IPEndPoint(IPAddress.Parse(ipOfServer), portServerIsListeningOn);
sending_socket.SendTo(Encoding.ASCII.GetBytes("Test"), sending_end_point);

// after I send data localendpoint gets initialized! and the server always respond through that port!

// get info
var port = sending_socket.LocalEndPoint.ToString().Split(':')[1];

// now wait for server to send data back
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, int.Parse(port));
byte[] buffer = new byte[1024];
sending_socket.Receive(buffer); // <----- keeps waiting in here :(

here is the server code:

// wait for client to send data
UdpClient listener = new UdpClient(11000);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 11000);        
byte[] receive_byte_array = listener.Receive(ref groupEP);
listener.Connect(groupEP);

// reply
byte[] dataToSend = new byte[] { 1, 2, 3, 4, 5 };
listener.Send(dataToSend, dataToSend.Length);
  • 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-06-10T13:45:01+00:00Added an answer on June 10, 2026 at 1:45 pm

    The Bind is giving you the information contained in the LocalEndPoint property not the router:

    This excerpt is from MSDN:

    The LocalEndPoint property gets an EndPoint that contains the local IP
    address and port number to which your Socket is bound. You must cast
    this EndPoint to an IPEndPoint before retrieving any information. You
    can then call the IPEndPoint.Address method to retrieve the local
    IPAddress, and the IPEndPoint.Port method to retrieve the local port
    number.

    The LocalEndPoint property is usually set after you make a call to the
    Bind method. If you allow the system to assign your socket’s local IP
    address and port number, the LocalEndPoint property will be set after
    the first I/O operation. For connection-oriented protocols, the first
    I/O operation would be a call to the Connect or Accept method. For
    connectionless protocols, the first I/O operation would be any of the
    send or receive calls.

    But you are correct in your understanding, UDP is a fire and forget style of sending data.

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

Sidebar

Related Questions

I've been told that depending on the YAML library used, when a list (not
I was told that I could use some sort of getEdge() and, define a
I was told that the iPhone does not support multitasking and multithreading. This did
I've been told that System.IO.MemoryStream need not be wrapped in a using block because
I have been told that a handle is sort of a pointer, but not,
I was told that this could be done by using SSIS. Can anyone refer
In Java I am told that when doing a null check one should use
I was told that if I would use Roots theme for wordpress, it would
Today I was told that we could introduce an MVC (or quasi-MVC) architecture to
I was recently told that it is not recomended to use the LIKE keyword

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.