Pages: [1]   Go Down
Author Topic: network server welcome-banner  (Read 463 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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?
Logged

Pages: [1]   Go Up
Jump to: