Go Down

Topic: network server welcome-banner (Read 494 times) previous topic - next topic

Theos

Hi all,

I'm trying to make a munin-node on an arduino-board with ethernet-shield, which will allow munin to query the connected temperature-sensors automatically over the network.

I've already implemented most of the munin-protocol and I'm able to retrieve all data from the arduino using telnet.

There is one part missing and I don't know how to do that. The munin-protocol requires that the server (the arduino-board) will print a welcome-banner when a client connects.

Is it possible to detect that a new client has connected to the server and send him a welcome-banner?

(of course I will make it opensource if I manage to get it working correctly)

Theos

It looks like I've got it working now. I think it's not very pretty, but it does the job.

Code: [Select]
void Munuino::process() {
 for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
   Client client(sock);

   if (EthernetClass::_server_port[sock] == muninport) {
     if (client.status() == SOCK_ESTABLISHED) {
       if (headerSent[sock] == 0) {
         client.println("# Muduino munin node");
         headerSent[sock] = 1;
       }
     }
     else {
       headerSent[sock] = 0;
     }

   }
 }

 Client client = _server.available();
 if (client) {


Does anyone know a nicer solution?

Go Up