Public Member Functions
BeaconTimer Class Reference

Brief description of class still missing. More...

#include <BeaconTimer.h>

Inheritance diagram for BeaconTimer:
GpCoreTools::Timer

List of all members.

Public Member Functions

 BeaconTimer (uint16_t port, int beaconDelay=2000)
virtual bool exec ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

BeaconTimer::BeaconTimer ( uint16_t  port,
int  beaconDelay = 2000 
)

Description of constructor still missing

References GpCoreTools::Timer::setInterval().

    : Timer()
{
  setInterval(beaconDelay);
  _fd=socket(AF_INET,SOCK_DGRAM,0);
  if(_fd<0) {
    Log::write(0, "beacon socket error: [%i] %s\n", errno, strerror(errno));
    CoreApplication::exit(2);
  }
  int optval=1;
  if(setsockopt(_fd,SOL_SOCKET,SO_BROADCAST,&optval,sizeof(optval)) < 0) {
    Log::write(0, "beacon broadcast: [%i] %s\n", errno, strerror(errno));
    CoreApplication::exit(2);
  }
  _addr.sin_family=AF_INET;
  _addr.sin_addr.s_addr=Address::me().subnet().value();
  _addr.sin_port=htons(port);
}

Member Function Documentation

bool BeaconTimer::exec ( ) [virtual]

Performs action after timeout. If it returns true the timer is not single shot, i.e. deleted right after exec().

Implements GpCoreTools::Timer.

{
  if(_fd<0) {
    return false;
  }
  static const char * msg="WAUB";
  if(sendto(_fd, msg, 4, 0,(struct sockaddr *) &_addr, sizeof(_addr))<0) {
    Log::write(0, "beacon sendto error: %s\n", strerror(errno));
  }
  return true;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines