LAN Server Questions

i know, it's my first post. i'm new to networking, not arduinos, but still have a lot to learn.

so i'm making a server on a lan, and i've searched without satisfactory results. here are the questions:
-are the gateway, subnet, and server port used at all for lan?
-can i still use html to make a gui?

my setup will be a mega-2560 with a network shield, controlling (for argument's sake) about a dozen led's.

any help or guidance would be awesome. sorry for the n00b question, but someone has to ask it, right?

are the gateway, subnet, and server port used at all for lan?

Gateway is necessary only if your device should have Internet access. Subnet is necessary but you probably can live with the default 255.255.255.0 because it's used by all home devices. Server port is necessary too as the client will connect to that port and the server should know about. For a web server it's usually 80.

[can i still use html to make a gui?/quote]

Sure! Nobody will hold you back doing it.

Sure! Nobody will hold you back doing it.

ha, yeah, i walked into that one. i meant; will it work without internet access to the arduino?

Gateway is necessary only if your device should have Internet access.

so i can omit the gateway?

Subnet is necessary but you probably can live with the default 255.255.255.0 because it's used by all home devices. Server port is necessary too as the client will connect to that port and the server should know about. For a web server it's usually 80.

it's a lan server, and won't be connected to the internet at all. also, i successfully ran the example sketch below, and i notice that it contains no subnet or gateway, but almost every other example, especially those with html gui's, do contain them. i have no issue adding them, but i'm not sure what's required.

/*
  Web Server Demo
  thrown together by Randy Sarafan
 
 Allows you to turn on and off an LED by entering different urls.
 
 To turn it on:
 http://your-IP-address/$1
 
 To turn it off:
 http://your-IP-address/$2
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Connect an LED to pin D2 and put it in series with a 220 ohm resistor to ground
 
 Based almost entirely upon Web Server by Tom Igoe and David Mellis
 
 Edit history: 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>

boolean incoming = 0;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(191,11,1,1); //<<< ENTER YOUR IP ADDRESS HERE!!!

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  pinMode(2, OUTPUT);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        
        //reads URL string from $ to first blank space
        if(incoming && c == ' '){ 
          incoming = 0;
        }
        if(c == '

){
          incoming = 1;
        }
       
        //Checks for the URL string $1 or $2
        if(incoming == 1){
          Serial.println(c);
         
          if(c == '1'){
            Serial.println("ON");
            digitalWrite(2, HIGH);
          }
          if(c == '2'){
            Serial.println("OFF");
            digitalWrite(2, LOW);
          }
       
        }

if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

also, i successfully ran the example sketch below, and i notice that it contains no subnet or gateway,

But it really does. When you call Ethernet.begin(mac,ip), these are the defaults:

For the gateway ip, it uses the first three numbers of the ip, and the fourth is 1. In your case, that would be 191.11.1.1. Same as the ip.

For the dns server, it uses the gateway ip. Again, 191.11.1.1.

For the subnet, it uses 255.255.255.0.

so if i set it up like this (snippet):

...
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(191,11,1,1);
EthernetServer server(80);

void setup()
{
   Ethernet.begin(mac, ip);
...

without specifying gateway or subnet, it should work, regardless of what type (lan/wan) network i use?

so after playing around a bit, i now know that it does work. thanks everyone for pointing me in the right dirrection.