Arduino Ethernet W5100 TCP Setup

Hello All,

I am trying to get started with the Ethernet W5100.
I would like to use TCP IP communication to receive and send messages with VVVV or Python.

I have found examples for UDP data setup, but not a simple TCP setup.

I am not trying to get information from a website or anything kind of online server. I am just trying to send a string from a computer program to the arduino and have the arduino send back another string.

This post below was the most clear example I could find, although it does not seem to be TCP either.
http://forum.arduino.cc/index.php?topic=123756.0

Thank you in advance for the help! I tried to find existing information online before posting. I am quite surprised that the TCP functionality of the W5100 is not well documented.

Kind regards,
-Jake

I am basically just looking for a "Hello World" like example for TCP IP.

Ok, I think I have this partially working now. I stripped down the code from the example in the link and got "Hello world" sending, receiving and printing.

If anyone has comments on how this could be improved, please advise.

/* 
 *  Print message received from TCP IP server in Serial Monitor ("Hello World" - TCP IP)
 *  (With parts borrowed/stolen from Nick Gammon & Michael E. Landon)
 *  http://forum.arduino.cc/index.php?topic=123756.0
 */
#include <Ethernet.h>

// Set values below to match your network needs:
byte mac[] = {0x54, 0x52, 0x49, 0x41, 0x44, 0x00};   // MAC Address
byte ip[] = {192, 168, 2, 99};                       // Network Address
byte gateway[] = {192, 168, 0, 1};                   // Gateway Address
byte subnet[] = {255, 255, 0, 0};                    // Subnet Mask
EthernetServer server(4444);                         // Set Server Port
EthernetClient client;                               // Define client


void setup() {
  // put your setup code here, to run once:
  Ethernet.begin(mac, ip, gateway, subnet);          // Start the Ethernet connection
  server.begin(); 

  Serial.begin(9600);
}

void loop() {
  char inByte;                                      // Set up a character buffer to grab the input
  
  client = server.available();                      // Check for server availability
  
  while(!client){
    client = server.available();                    // Read the character in the buffer
  }

  if(client.available()){
      inByte = client.read();
      if (inByte == 13){                            //CarriageReturn
        Serial.println("");
      }
      else{
        Serial.print(inByte);                       //Print "Hello World" 
      }
    }
  }

This does take a loooooonnnnnngggg time to start receiving messages... like ~20 seconds
I am not sure if this is a problem on the sending or receiving end.

I have the client setup and ready to send before I start the arduino.

After the delayed start, seems the data is always showing in the monitor much later than when sent.

I can slow down the sending so that the arduino catches up with its serial printing, but the starting connection still takes a long time for some reason.