I am using the EtherTen board by Freetronics.
I am also working through the examples in “Programming Arduino” by Si.
Sketch 10-02 is a simple Arduino server that allows setting pins over the network from a browser client.
A line in the code reads:
EthernetServer server(80);
This I believe sets the listening TCP port on the Arduino to 80.
Everything works fine when uploaded, including ability to ping the IP address assigned to the Arduino.
If I change the port address in the code from 80 to 81
ie. EthernetServer server(81);
I can no longer ping the Arduino, and of course the Arduino server does not respond.
Being new to the world of microprocessor programming I am probably missing something very basic here, but I would appreciate any help.
Timbergetter:
including ability to ping the IP address assigned to the Arduino.
Do you mean literally running the 'ping' command from a command prompt? I wouldn't expect that to be affected by the TCP port change. Are you carrying out the ping from a machine in the same network as the Arduino?
Yes I do mean literally running a ping from a command prompt. And, I too would not expect a port change to affect the ability to ping the tcp/ip address.
Nevertheless when I attempt to change the TCP port to anything other than the default http port number (anything other than 80) it appears that the Arduino is no longer accessible over the network.
Nevertheless when I attempt to change the TCP port to anything other than the default http port number (anything other than 80) it appears that the Arduino is no longer accessible over the network.
I run mine, a Duemilanove with official Ethernet shield, on port 60 all the time. If you are unable to, there is something wrong with your network settings, the code on the Arduino, or the way that you are trying to access the Arduino-as-server from a client.
Many thanks for your comments PaulS and others. The attached code runs as intended in every way until it is changed. When I change line 10 from “int serverPort = 80;” to “int serverPort = 81;” I can no longer get a command prompt response to “ping 192.168.10.30”, nor can I get any browser response to http://192.168.10.30:81.
The Arduino with Ethernet shield is on one end of the ethernet cable. What's on the other end? If it's a router, is that router configured to forward port 81 (or other port) messages. Mine is. Yours may not be.
The other end of the ethernet cable is connected to my LAN which is in turn connected to my router / gateway. I had thought because both the client PC and the Arduino were both on the same local sub-net, that forwarding by the router’s NAT would not be required. However when I set up the router’s NAT to forward Port 81 to 192.168.10.30 both pings and http both work fine. I don’t understand this behaviour. I thought that port forwarding was only required for traffic that entered through the WAN side of the router.
Many thanks PaulS for making progress on this problem.