I have made a simple server using the YUN SERVER and CLIENT Libraries./ The server runs on a loop and waits for a client to connect. After connection it sends the client a simple message and then disconnects the client.
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
#define PORT 6666
YunServer server(PORT);
int pin =13;
void setup() {
Serial.begin(115200);
Bridge.begin();
server.noListenOnLocalhost();
server.begin();
}
void loop() {
YunClient client = server.accept();
if(client.connected())
{
digitalWrite(pin,HIGH);
//startup
startup_msg(client);
}
else
digitalWrite(pin,LOW);
delay(500);
}
void startup_msg(YunClient client)
{
client.print("SAndTerm");
client.stop();
}
Well this code runs smoothly for few hours. But after that, it stops responding to any client request. I guess the server crashes. I have to restart the YUN to get it working again.
Is there anyway I can run this without it getting to crash? Well I want it to be running just like a normal server would.