Why are you using W5100 DLL? That is only needed when using USBizi-devices that needs W5100 to run networking.
You have full blown socket support on your FEZ Cobra and you do not need that DLL.
Both, USBizi and EMX have the same interface so they both run the same socket code. It is just that larger devices run the full NET version (which is what you need) and smaller devices run the GHI version, w5100 (which you do not need)
Since you indicated that the Cobra has fill blown socket support I attempted to setup an application similar to one I already use in regular .NET but there doesn’t seem to be assemblies for “System.Net” or “System.Net.Sockets”. I can’t find any reference to a socket anywhere in the NETMF.
All I am attempting to build here is a simple TCP server that listens for a client to connect and exchange data with.
I got the TCP server to run properly and it now exchanges data with my PC using TCP.
Do you know of any way to detect when a socket is no longer connected (i.e. the PC end disconnects)? The Microsoft help for the Socket class indicates there is a property named “Connected” but this property doesn’t appear to be available in NETMF.
I found a way to detect disconnect although it’s a bit ugly. If I try to send data to a socket that has disconnected an exception is thrown. So my code can periodically try to send data and if the exception occurs I will know the connection was lost.
Knowing when a remote socket has been terminated abnormally is one of the difficulties of TCP/IP.
If the remote socket is closed cleanly, by an actual close method, you will usually get a completed read with a length of zero.
But, if the close is not clean, such as when the power is pull on the remote, the fun starts.
To get to the answer quickly, send a heartbeat, as you have done, is the answer.
There an internal heartbeat available, on some operating systems, which will determine when the remote has been abnormally closed. But, the timing of this feature varies, and whether it is turned on or off by default varies.
Some versions of windows have it turned on by default, but the heartbeat period is two hours.
I see you’re using port 80, so you probably want to create a HTTP server.
You can use the HttpListener class to handle requests. I’ve created a WebServer class that’s based on that HttpListener class. You can find the source at [url]http://blog.fastload-media.be/?p=45[/url]