Arduino and the Ethernet

Hello again Arduino Community
I have an Ethernet shield for my Arduino Mega ready to send out data to the world. However, my knowledge of the great internet is limited. I did not think it was this complicated. I have given the Arduino (thanks in large part to available libraries) an IP address as well as port and Mac address. I have another device (Computer running LabVIEW) ready to communicate. I have serial debug right after If (client) to verify that I even see the client. And I am getting nada. I know I am going to get responses of, "This is vague, need more data...blah blah blah." But what I am really looking for is perhaps a list of what I need to do to see to that this works properly. At the moment I am attempting to resolve this using TCP. Perhaps that is my issue?

TCP is good. Do you want the Arduino to be the client or server? Here are examples of both.
http://playground.arduino.cc/Code/WebClient
http://playground.arduino.cc/Code/WebServerST

I want it to be the Server. It's going to be working and storing data and I need that data to be streamed and read in Real-Time

There is the link to my server code above. You might want to search the forum for zoomkat's server code also. He uses the w5100 and SD card well. If you plan on using the two together, he is the guy.

Well, I tried the server code you provided and I will admit that I like it much more than the available examples. However, I am still running into the same issue with LabVIEW (which I know, this is not a LabVIEW forums). But the problem is that I am trying to do a read in LabVIEW and yet I guess there's no data being sent. But the problem goes even sooner. I put a serial.print right after the if(client) and never get the print. So apparently I am never connecting. Just what exactly is needed to make these connections? Anything more than an IP address? A Handshake?

I mean, it really looks like a matter of, there is indeed a TCP connection, but LabVIEW is not sending anything to the Arduino, so maybe the Arduino has no idea there is a client? But then, surely the only way Arduino knows that there is a client is if LabVIEW sent some sort of byte to tell it that there's a client.

Try a web browser with the server code. I use PuTTY to test my code.

And you are correct. The server code needs the client to send something, not just make a connection.

The below is one way of streaming changing data to a web page from the arduino.

// zoomkat's meta refresh data frame test page 5/25/13
// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

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

const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
const int analogInPin3 = A3;
const int analogInPin4 = A4;
const int analogInPin5 = A5;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
unsigned long int x=0; //set refresh counter to 0
String readString; 

//////////////////////

void setup(){
  Serial.begin(9600);
    // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.println("meta refresh data frame test 5/25/13"); // so I can keep track of what is loaded
}

void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readString.length() < 100) {
          readString += c; 
         } 
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received
          Serial.println(readString);

          //output HTML data header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          //generate data page
          if(readString.indexOf("data") >0) {  //checks for "data" page
            x=x+1; //page upload counter
            client.print("<HTML><HEAD>");
            //meta-refresh page every 1 seconds if "datastart" page
            if(readString.indexOf("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>"); 
            //meta-refresh 0 for fast data
            if(readString.indexOf("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>"); 
            client.print("<title>Zoomkat's meta-refresh test</title></head><BODY>
");
            client.print("page refresh number: ");
            client.print(x); //current refresh count
            client.print("

");
            
              //output the value of each analog input pin
            client.print("analog input0 is: ");
            client.print(analogRead(analogInPin0));
            
            client.print("
analog input1 is: ");
            client.print(analogRead(analogInPin1));
                        
            client.print("
analog input2 is: ");
            client.print(analogRead(analogInPin2));
            
            client.print("
analog input3 is: ");
            client.print(analogRead(analogInPin3));
                                    
            client.print("
analog input4 is: ");
            client.print(analogRead(analogInPin4));
            
            client.print("
analog input5 is: ");
            client.print(analogRead(analogInPin5));
            client.println("
</BODY></HTML>");
           }
          //generate main page with iframe
          else
          {
            client.print("<HTML><HEAD><TITLE>Zoomkat's frame refresh test</TITLE></HEAD>");
            client.print("Zoomkat's Arduino frame meta refresh test 5/25/13");
            client.print("

Arduino analog input data frame:
");
            client.print("&nbsp;&nbsp;<a href='http://192.168.1.102:84/datastart' target='DataBox' title=''yy''>META-REFRESH</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/data' target='DataBox' title=''xx''>SINGLE-STOP</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/datafast' target='DataBox' title=''zz''>FAST-DATA</a>
");
            client.print("<iframe src='http://192.168.1.102:84/data' width='350' height='250' name='DataBox'>");
            client.print("</iframe>
</HTML>");
          }
          delay(1);
          //stopping client
          client.stop();
          //clearing string for next read
          readString="";
        }
      }
    }
  }
}

Hello, thank you for your code. I've tried to run it and cannot. I've entered my own IP information as well as gateway etc. The same values I had been using b4. I am getting 0 browser connection. Am I using your code incorrectly? Also, I have been reading through your code and I am not sure this entirely fixes my problem. I am also encountering the issue that when there is a client, the code stays in that while loop. I need the code to execute stuff and just print to the browser once. I have been tinkering with that trying to figure out how to get the HTML to just print and then disconnect and continue on with its main tasks.

And yes, I fixed the couple of bugs I located.