Hello,
i’m trying to send udp-packets over my mountaineer ethernet board, but i’m getting an exception while sending the packet.
My Code:
private void InitEthernet()
{
ethernetForMountaineerEth.UseStaticIP("192.168.10.10", "255.255.255.0", "192.168.10.1");
ethernetForMountaineerEth.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(Ethernet_NetworkUp);
}
private void SendUdpCommand(string command)
{
System.Net.Sockets.Socket socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPAddress destinationIP = new IPAddress(new byte[] { 192, 168, 10, 125 });
IPEndPoint destinationEndPoint = new IPEndPoint(destinationIP, 5000);
Byte[] sendBytes = Encoding.UTF8.GetBytes(command);
try
{
//socket.Bind(destinationEndPoint);
socket.SendTo(sendBytes, destinationEndPoint); <----------------Exception here. The same with the bind method.
}
catch(Exception exc)
{
Debug.Print(exc.ToString());
}
}
Hope someone can help me. I am using NETFM4.2(QEF2).