Arduino Yun - How to close http client connections?

Hi there!
I am using this sketch code for Arduino Yun to make Http Connetions, but i want to close the connections each time I make them.

In arduino Ethernet there was client.stop function.

what can I do in Arduino Yun?

#include <Bridge.h>
#include <HttpClient.h>

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  Serial.begin(9600);
  while(!Serial);
}

void loop() {
  HttpClient client;
  client.get("http://arduino.cc/asciilogo.txt");

  while (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  Serial.flush();

  delay(5000);
}

Same thing

Hi Federico,

I get a:

Arduino: 1.5.6-r2 (Mac OS X), Board: "Arduino Yún"
error: 'class HttpClient' has no member named 'stop'

Do you know if that have been removed? I can still see it in the documentation. My sketches run without it so I always assumed in was somehow integrated inside the HttpClient.

What you're doing is fine.

HttpClient inherits from Process, and is implemented by calling curl on the Linux side. The destructor for Process calls close(), so this will be called when your client instance is destroyed before loop() returns.

cheers :slight_smile:

nicklin: What you're doing is fine.

HttpClient inherits from Process, and is implemented by calling curl on the Linux side. The destructor for Process calls close(), so this will be called when your client instance is destroyed before loop() returns.

On the server side ,It looks like it never closes the http get request, but timeouts after sometime.