@ Mike - First of all, I don’t have any ENC28 module. Is it even compatible with Spider kits?
Secondly, I don’t use DHCP. So when I enable DHCP on my interface, the 0.0.0.0 value is assigned to the IP, subnet and gateway.
I’ve modified my program to be more verbose.
void ProgramStarted()
{
Debug.Print("Program started");
if (!ethernetJ11D.NetworkInterface.Opened)
{
Debug.Print("Opening interface");
ethernetJ11D.NetworkInterface.Open();
Debug.Print("Interface opened");
}
ethernetJ11D.UseStaticIP("192.168.0.8", "255.255.255.0", "192.168.0.1");
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("192.168.0.5"), 7777);
ethernetJ11D.UseThisNetworkInterface();
new Thread(() =>
{
try
{
//Thread.Sleep(3000);
PrintNetworkState();
Debug.Print("Connecting socket");
socket.Connect(endpoint);
Debug.Print("Socket connected");
byte[] msg = new byte[] { 0, 1, 2, 3, 4 };
socket.Send(msg);
}
catch (SocketException e) { Debug.Print("SocketException: " + e.ErrorCode); }
catch (Exception e) { Debug.Print(e.GetType().ToString() + ": " + e.Message); }
finally { PrintNetworkState(); }
}).Start();
}
void PrintNetworkState()
{
StringBuilder builder = new StringBuilder();
builder.Append("Up=");
builder.Append(ethernetJ11D.IsNetworkUp);
builder.Append("; ");
builder.Append("Connected=");
builder.Append(ethernetJ11D.IsNetworkConnected);
builder.Append("; ");
builder.Append("IP=");
builder.Append(ethernetJ11D.NetworkInterface.IPAddress);
builder.Append("; ");
builder.Append("Mask=");
builder.Append(ethernetJ11D.NetworkInterface.SubnetMask);
builder.Append("; ");
builder.Append("GW=");
builder.Append(ethernetJ11D.NetworkInterface.GatewayAddress);
Debug.Print(builder.ToString());
}
For some reason now I get 10065 error code (WSAEHOSTUNREACH: No route to host).
[quote]Program started
Opening interface
Interface opened
Up=True; Connected=True; IP=192.168.0.8; Mask=255.255.255.0; GW=192.168.0.1
Connecting socket
SocketException: 10065
Up=True; Connected=True; IP=192.168.0.8; Mask=255.255.255.0; GW=192.168.0.1
[/quote]
Another curios observation: when I uncomment the Thread.Sleep invocation, the Socket.Connect succeeds, but the Socket.Send hangs for a few seconds and then throws the 10053 error code (WSAECONNABORTED: Software caused connection abort).
[quote]Program started
Opening interface
Interface opened
Up=True; Connected=True; IP=192.168.0.8; Mask=255.255.255.0; GW=192.168.0.1
Connecting socket
Socket connected
SocketException: 10053
Up=True; Connected=True; IP=192.168.0.8; Mask=255.255.255.0; GW=192.168.0.1[/quote]
In both of these cases I can still ping the Spider from my PC (192.168.0.5).
EDIT
Today I’ve forgotten to turn off my firewall. Now the Spider sends the data to my PC without any problems, but only with the Thread.Sleep call uncommented. Why is that?