I've just followed the advice from JimboZA & now have WebServer working fine adding the line of code
EthernetServer server(8085);
I then went back and changed code to the original EthernetServer server(80); and that also works OK.
For others following this post in my TP-Link modem router I have set up NAT Virtual Server - which is Port Forwarding as follows:
Server Name: Arduino-8085
External Port Start: 8085
External Port End: 8085
Protocol: TCP/UDP
Internal Port Start: 8085
Internal Port End: 8085
Server IP Address: 192.168.1.177
WAN Interface: ppp0.2 (this may just relate to my ISP iprimus here in Australia
Status: Enabled
I also have a similar entry for port 80 instead of 8085 and that works fine.
Now as previously mentioned to get around my ISP providing me with just a dynamic external IP I have been using both noip.com and also duckdns.org . I notice JimboZA uses some redirection server gotdns which must be similar. e.g. http://jimboza.gotdns.com:8085
Although duckdns periodically changed my external IP address all I need to do is enter username.duckdns.org:8085/ and if finds its way to to my Arduino Server
I've noticed duckdns redirection seems to over-ride and external IP address specified bu NOIP.Com
QUESTION:
This has been a learning curve for myself & maybe others following this post with respect to Service Port numbers but does anyone know the full range of ports numbers available and is their any restriction on what can be used by Arduinos ???
@JimboZA: Your server code failed. I locked it up. If you haven't gotten my PM, reset it now.
This fix for that is here: http://playground.arduino.cc/Code/WebServerST
Look for the checkSockStatus() function in the new server code. It is about 3/4 down the page at the end of the first server example.
You can put the call in loop(). I put it in the myStuff() function because that is where I call ShowSockStatus() when checking my sockets during the debug. The ShowSockStatus() function is also very handy.
@rbright: If you are going to expose your Arduino server code to the internet, you should also include that checkSockStatus() function.
Here is how to add that function. Then call it every iteration of your loop() function.
// add these includes
#include <utility/w5100.h>
#include <utility/socket.h>
// add these arrays to your global variables
unsigned long connectTime[MAX_SOCK_NUM];
byte socketStat[MAX_SOCK_NUM];
// and this function to the end of your sketch
void checkSockStatus()
{
unsigned long thisTime = millis();
for (int i = 0; i < MAX_SOCK_NUM; i++) {
uint8_t s = W5100.readSnSR(i);
if(s == 0x17) {
if(socketStat[i] == 0x14) {
connectTime[i] = thisTime;
}
else if(socketStat[i] == 0x17) {
if(thisTime - connectTime[i] > 30000UL) {
Serial.print(F("\r\nSocket frozen: "));
Serial.println(i);
close(i);
}
}
}
else connectTime[i] = thisTime;
socketStat[i] = W5100.readSnSR(i);
}
}
All of the above is excellent information for which I thank the contributors.
As I asked above "with respect to Service Port numbers but does anyone know the full range of ports numbers available and is there any restriction on what can be used by Arduino"
To assist others searching on Port Forwarding problems, how do we change the heading of the topic to something like "SUCCESS - Port Forwarding"
Alternatively maybe Moderator can make something like this a "sticky topic".
Port forwarding and the number of available ports depends on the type of router and how the maker set up port forwarding. Below is a screen capture of my Netgear 614 wireless router.
rbright:
To assist others searching on Port Forwarding problems, how do we change the heading of the topic to something like "SUCCESS - Port Forwarding"
You can modify the heading yourself: just make sure you do it in the opening post not one of the replies.
Go to the post and choose More > Modify in the bottom right corner.
I wouldn't advocate this particular thread as a sticky- it's a bit haphazard, as threads are wont to be. Maybe "someone" 8) could write a "port-forwarding 101" though...
Zoomcat what I see is the specific ports you have set up on your Modem/Router but what is the theoretical highest port number e.g. could someone add a port number 9999 or higher.
To add to this question could someone add on their modem/router a Start Port of 0 and End Port of 9999. I'd expect this may be a security risk but so what if you don't have hardware connected to specified ports. I'd expect there may be some PC system devices which may be in that range.
@zoomkat: I don't know if you noticed, but that is your server code I was crashing. Insure you include my fix to your server code or you may become a victim of that hack.
CatweasleNZ was the user who brought this bug to my attention. Thanks again to him.
I'll look at the server fix. Port 84 below is the only one with an arduino currently connected. Not sure just what was running on the arduino, but it probably was server code that off loaded files from the SD card.
[LAN access from remote] from 125.64.35.67:40044 to 192.168.1.102:84 Sunday, Nov 23,2014 05:45:55
JimboZA thanks for your previous posts and published code which I'm using as a template for doing something similar. Can you please post your current code ?
Now that I have a basic web server running successfully from remote sites using port forwarding & as I've also been able to get twitter posting working, I'm hoping to now merge the webserver & twitter at some time into a UNO hopefully within the memory restraints else I'll need to buy a MEGA to run the lot all from same hardware along with some I/O monitoring from a standalone Arduino plugged into a spare modem/router port.
End aim it to be able to receive tweets when a front gate opens / closes with timestamping from a RTC and also be able to look at my site from a remote browser for a general overview of what is happening at home.