I have a Spider, and I added the module: Ethernet_J11D.
When I trying to send a UDP packet I get an Exception (while receiving UDP packets goes fine, without no problems).
the major code:
// GTM.Module definitions
Gadgeteer.Modules.GHIElectronics.Ethernet_J11D ethernet_J11D1;
Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClientDP;
public static void Main()
{
//Important to initialize the Mainboard first
Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();
Program program = new Program();
program.InitializeModules();
program.ProgramStarted();
program.Run(); // Starts Dispatcher
}
private void InitializeModules()
{
// Initialize GTM.Modules and event handlers here.
usbClientDP = new GTM.GHIElectronics.UsbClientDP(1);
ethernet_J11D1 = new GTM.GHIElectronics.Ethernet_J11D(7);
}
Socket Sender;
Socket Receiver;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
ethernet_J11D1.Interface.Open();
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D1.Interface);
//not working
// ethernet.UseStaticIP(ethernet.NetworkSettings.IPAddress, ethernet.NetworkSettings.SubnetMask
// , ethernet.NetworkSettings.GatewayAddress, ethernet.NetworkSettings.DnsAddresses);
ethernet_J11D1.Interface.NetworkInterface.EnableStaticIP(IPAddress.GetDefaultLocalAddress().ToString(), "255.255.0.255",
ethernet_J11D1.NetworkSettings.GatewayAddress);//, ethernet.NetworkInterface.DnsAddresses);
//not working
ethernet_J11D1.NetworkUp += new Module.NetworkModule.NetworkEventHandler(EthernetNetworkUp);
Sender = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Receiver = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Receiver.Bind(new IPEndPoint(IPAddress.Any, 12340));
try
{
//a valid end point
var endP = new IPEndPoint(new IPAddress(new byte[] {198, 168, 0, 10}), 44544);
//throws the excption
Sender.SendTo(new byte[] { 22, 2, 2 }, endP);
}
catch (Exception e)
{
Debug.Print(e.Message);
}
the exception:
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::sendto [IP: 0000] ####
#### System.Net.Sockets.Socket::SendTo [IP: 0022] ####
#### System.Net.Sockets.Socket::SendTo [IP: 0011] ####
#### GadgeteerApp2.Program::ProgramStarted [IP: 00be] ####
#### GadgeteerApp2.Program::Main [IP: 0015] ####
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
my SW/FW versions:
Microsoft .NET Micro Framework v4.2 (QFE2)
SDK Versions:
GHI Premium SDK v1.0.2
GHI OSHW SDK v1.0.3
GHI .NET Gadgeteer v1.6.12.0
Libraries Versions:
Premium libs v4.2.9.0
OSHW libs v4.2.4.0
Firmware Version:
EMX (spider) v4.2.9.0, TinyBooter v4.2.9.0