Problem with ethernet shield - can't open again a socket after warm reboot

i am using an ethernet shield with a domino as a telnet server.

everything is running fine, except when i reset the device, unable to connect again. seems the ethernet device keeps an open socket in memory and try to close it… but it’s stuck in a loop.

i have to power off and power on the device. to be able to open again a socket.

how can i really initialize the ethernet shield ?

the current driver is beta and very buggy. We are working on a new driver (native driver) to make this much better.

do you when (approx) it will be available ? (even a beta)

otherwise i ll start to modify the existing one by myself …

We are working on it full-time but with embedded systems it is impossible to tell

I’ve heard of Arduino problems related to RESET and ethernet shields, wonder if it’s the same deal here given we’re using the same shields.

I believe a capacitor cures the reset problem.

Yep, it’s a hardware issue. I have had the same issue. More info here:

After a few test, it seems that I only have this problem when i restart the project in debugging mode (with the board connected to vs through usb)

It gets stuck in the while loop there :

 public void Close()


                    byte s = _scoket_number;

                    W5100.RegisterWrite(s, W5100.SocketRegisters.CR, (byte)CR_val.Sn_CR_CLOSE);

                    while (W5100.RegisterRead(s, W5100.SocketRegisters.CR) != 0)


                    W5100.RegisterWrite(s, W5100.SocketRegisters.IR, 0xFF);

                    SocketIsUsed[_scoket_number] = false;


Otherwise seems ok even during cold or warm (reset) boot when the device is not attached to my computer.

So it’s not a big issue finally…

concerning :

it was the opposite problem… only a cold boot (power off/on) would help, reset was no help

Your issue though is that the default reset circuitry on the Ethernet shield does not do an effective job of resetting the Wiz chip when the Fez (or Ard) is reset. So the talk about hardware is actually that if you can manually reset the ethernet chip in your code, with a re-routing of the RESET pin on the shield to an IO port, you get the same result.

In your case, a full power off is resetting the Wiz chip correctly and closing any open connection, so that it will respond correctly.

If you wire the reset to an io pin it will work. Just reset the wiz in your code and everything will work correctly. I have made a modbus tcp server on a fez mini and it works. I can disconnect the ethernet cable connect it back and the modbus master happily continues. I can switch off/on the board and the everything continues just working fine.
I just hope that the native code is a bit faster then the code I am using now because it is not that fast when I send over 100 integers = 200 bytes. I am convinced that the guys of Fez will do better.
If only the board could get his power over ethernet then the system would rock. POE is the future in my opinion.

Would this help implementing POE in your project? :wink:

I have a set of those PoE splitters. Here’s a DIY option [url][/url]

[url][/url] is another option for a shield - obviously doesn’t help with a Cobra or Rhino :slight_smile:

I looked at the ethernet shield with poe and this is what I am looking for. Imagine now having that and a usbizi including the voltage regulation from 24vdc or a bit more (industrial voltage) all on one small pcb.
Thanks for the info guys.

If you use commercial PoE injectors/switches, then you need a good conversion option, yeah. The good news is that the Freetronics guys have built the shield in a way that you can use their [url][/url] adapter to do just that. And if you don’t have commercial grade PoE you can just inject the voltage you want :slight_smile:

how can i do that ?

i m developing a small telnet server for tinyclr

when i connect for the first time it’s all good

then once i disconnect from the server, it’s not possible to reconnect again. any advice on how to do this ?

concerning the uSocket object :

how can i know if i m disconnected ?
how can i listen again with the same socket ?

Like I said earlier, we are actively working on an official driver. Just wait couple weeks and it will be all explained and better supported. The driver everyone is using is for demonstration purposes only.

Also, the driver is all open source so feel free to open the W5100 datasheet and fix the drivers anyway you find appropriate.

I followed your advice and went through the W5100 datasheet.

Here is a solution to the problem of warm reboot.

in the FEZ_Shields_Ethernet.cs, in the constructor of uSocket you can change the line :

W5100.RegisterWrite(s, W5100.SocketRegisters.MR, (byte)(protocol));
// for 
W5100.RegisterWrite(s, W5100.SocketRegisters.MR, (byte)(protocol +128));

the 128 indicates to the W5100 that he must reinitialize itself first (SOFT RESET ;D )

of course… it’s just a temporary fix when we use just one socket at a time…

now i’m working on my second issue… i can connect once to my tinyclr telnet server but not the second time… i ll post something when this will be solved :wink:
stay tuned boyz !!!

Now i can close and open again a connection on my tinyclr telnet server…

here is how i did it :
(again… this post is just to help people to quick fix their soft until the magic wizards from ghi or wherever eventually post the new driver)

tested if the connection was closed in AvailableBytes function :

  public int AvilableBytes

                        //< my changes, first check if we are not disconnected or something else bad...
                        switch ((int)W5100.RegisterRead(_scoket_number, W5100.SocketRegisters.SR))
                            case 0:
                            case 1:
                            case 0x1c:
                                return -1;
                            default :
                                break ;
                        //  === changes stop here

                        return W5100.getSn_RX_RSR(_scoket_number);



the new thing is that availablebytes now return -1 if you have to reinitialize the listening server.
To do it, i changed the constructor of usocket, i moved the logic into ReInit function and called this new Reinit functions when i Detected that my TCPClient was no more connected… so I m ready for a new connection :

              private Protocol protocol;
                private UInt16 port;
                public uSocket(Protocol protocol, UInt16 port)
                    this.protocol = protocol ;
                    this.port = port;

                public void ReInit()

                    byte s;

                    for (s = 0; s < 4; s++)

no you can implement a nice socket server (telnet like), this way :

static class MyServer 
//declarations and stufff...
static public void Initialize()
               soc = new FEZ_Shields.Ethernet.uSocket(FEZ_Shields.Ethernet.uSocket.Protocol.TCP, 23); //or the port you like

               t= new System.Threading.Thread(new System.Threading.ThreadStart(listenLoop));

           private static void listenLoop()
               while (true)
                   while (!soc.Listen()) ;
                   while (true)

                       int n = soc.AvilableBytes;
                       if (n < 0) break; //disconnected so get out the while
                       if (n > 0)
                           byte[] buffer = new byte[n];
                           soc.Receive(buffer, n);
                           soc.Send(buffer, n); //echo 
                   soc.ReInit(); //reinitialize the socket

hope you ll all enjoy tinyclr as much as i do :wink: