Arduino Ethernet - as TCP Client, keep sending data stream.

Hi,

I have tried for sometime now to stream some data from an Arduino Nano with Ethernet Shield, I can successfully send the data once. Using client.print(xxxx) and then client.stop() to send the data.

But how can I Send data without closing the TCP connection to my TCP Server?

#include <UIPEthernet.h>
EthernetClient client;
void setup() {

  Serial.begin(9600);

  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  Ethernet.begin(mac);

  Serial.print("localIP: ");
  Serial.println(Ethernet.localIP());
  Serial.print("subnetMask: ");
  Serial.println(Ethernet.subnetMask());
  Serial.print("gatewayIP: ");
  Serial.println(Ethernet.gatewayIP());
  Serial.print("dnsServerIP: ");
  Serial.println(Ethernet.dnsServerIP());
  delay(1000);
}
void loop() 
{
  Serial.println("Try to connect to 10.0.0.18");
  if (client.connect(IPAddress(10,0,0,18),55056))
    {
      Serial.println("Connected");
      while(client.available()==0)
      {
        client.print("TEST"); // Data to stream, could be an analog input or something like that. 
        break;
      }
      client.stop();    
    }
    else
    {
      Serial.println("Failed to connect");
      delay(1000);
    }
}

Thanks in Advance
Ramgaard

That depends on the server. If the server is a port 80 http server, you can use the "Connection: keep-alive" parameter when you send the request. Requires some fancier footwork than just the standard web page request and receive.

My plan is not use a http web server.
But thats maybe the only way to do it?

I Just tought i could make a direct connection where i didn't have to close connection, maybe another library?.

Thanks for the quick answer

Sure. I have used a TCP client-server connection before. It works ok, but tricky to maintain if the transport is flaky. Have you considered UDP?

I Just tought i could make a direct connection where i didn't have to close connection, maybe another library?.

You might try a telnet connection, but you have not mentioned just what the gizmo is on the receiving end.