How do I fix Playground sketch with missing reference?

I want to use the SurferTim Webserver example listed in the Arduino Playground at WebServerST in Playground .

However when I try to compile it, I get the “No such file or directory” error for the line “#include <utility/socket.h>”

There is a “socket.cpp” in the ethernet library above “utility” but no header file.

How do i modify the sketch to take account of the Arduino changes since the sketch was written?

utility/socket.h was removed from the Ethernet library in version 2.0.0. The easiest fix would be to roll back to the newest version before it was removed:

  • Sketch > Include Library > Manage Libraries
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "ethernet".
  • Press Enter.
  • From the search results, click on "Ethernet Built-In by Various".
  • From the dropdown version menu, select "1.1.2".
  • Click the "Install" button.
  • Wait for the installation to finish.
  • Click the "Close" button.

Note that support for the W5200 and W5500 Ethernet controllers was added in Ethernet library 2.0.0. Version 1.1.2 only supported the W5100.

Modifying the sketch to work with Ethernet 2.0.0 would be the best solution. I'm not sure what would be required. Maybe someone else here will have advice on that.

Thanks Pert but I would prefer to run with the latest ethernet library to take advantage of those other Wiznet chips (and improvements)

Does anyone else know how to get around the socket.h reference to make Surfer Tims well featured web server sketch work?

Have you tried the obvious step of just commenting out, or removing, the include statement?

Yes, that was the first thing I tried. It resulted in an error with the " close(i);" saying "close was not declared in this scope.

I could just comment out the "close(i)" statement but it is the part of the code that puts this webserver above others; namely it closes dead sockets while other Arduino webservers use up their limited number of sockets and then lock up, even though they maybe inactive.

There's some good information on this topic here:

Thanks Pert,

Not a fix to the problem but may lead to a fix in the future. I just wanted to use webserver to run my application on. I may have to learn up on socket programming (of which i'm totally ignorant) and network protocols to fix the issue. What was to be an 'off-the-shelf' module to run my main application on has now become the main project. Cheers.

So many problems with this W5100-specific code. Fixing only “close(i)” is on the tip of the iceberg.

Thanks Paul for chipping in.

When you say ".... with this W5100-specific code..." are you referring to Surfer Tims webserver or the Arduino ethernet library code?

If its the latter would i be better off using a W5300 or W5500?