Some background on what I'm doing. I have a laptop (running VS2017) where I wrote a simple C# program (using UDPClient( ) ) to read UDP traffic sent from a microcontroller that communicates over Ethernet. The microcontroller uses port 8080 when it sends out UDP traffic to the laptop.
The program works fine when I execute it on my laptop (via VS2017 debug mode). When I try to run the application on another machine I cannot receive UDP traffic anymore. The 2 ways I've deployed the application to the new machine are,
- Using the App package generator in VS2017
- Creating a release build in VS2017 and copying the release folder to the destination machine.
Both methods allow the program to run (2nd computer) but NOT receive UDP traffic transmitted by the Microcontroller
I'm adding the most relevant code for review
The function below is part of a bigger class. I use it to setup the IpEndPt. The function is called with UDP_Port = 8080. So you sit and wait on port 8080 until the microcontroler sends UDP traffic to the laptop
SETUP UdpClient( )
public TCP_UDP_Comm(int UDP_Port)
{
IPEndPoint IpEndPt = new IPEndPoint(IPAddress.Any, UDP_Port);
UdpSock = new UdpClient(IpEndPt);
}
This is the function that receives UDP traffic communicated from the microcontroller
public async void LoopInfinitelyFor_UDP_Traffic()
{
while (true)
{
try
{
// Sit here and wait till a client connects
var RecResult = await UdpSock.ReceiveAsync();
string Response = Encoding.ASCII.GetString(RecResult.Buffer);
IPEndPoint ClientEndPoint = RecResult.RemoteEndPoint;
// Fire a textbox update event -- Received some data from a microcontroller
// The viewmodel code receives the event
// it will then update the text box property
RaiseEvent(this, new UDP_Event_Args.UDP_Event_Args() { TextToShow = Response });
string RemoteClientIP_Addr = ClientEndPoint.Address.ToString();
int RemoteCLient_Port = ClientEndPoint.Port;
}
}
}
The target machine has the latest .NET framework installed. I plan to install VS2017 on that machine to try and debug. The puzzling question is why this works fine on my Laptop (where VS2017) is installed yet when I deploy to a new machine the program fails to receive UDP traffic