#include <stdio.h>
#include <stdlib.h>
#include <winsock.h>

#include "ServerProtocol.h"
#include "utils.h"

#ifndef ONLYONE
	#include "LoggingMgr.h"
#endif

#define SENDBUFLEN 5  //length of send buffer (for sending commands in ServerProtocol.h)

class BroadCaster
{
private:
	int sock;
	struct sockaddr_in broadcastAddr;
	char *broadcastIP;
	unsigned short broadcastPort;
	char *sendString;
	int broadcastPermission;
	unsigned int sendStringLen;
	WORD wVersionRequested;           /* Version of Winsock to load */
    WSADATA wsaData;                  /* Winsock implementation details */
	bool m_bStopBroadCast;
	bool m_bAutoStarted;
	LoggingMgr *m_pLogger;

public:
	BroadCaster( LoggingMgr *lm );
	~BroadCaster( );
	int InitializeServer( void );
	void StartWinsock( void );
	void ShutdownWinsock( void );
	void StartBroadCast( void );
	void StopBroadCast( void );
	void BeginBroadCast( void );
	void setAutoStarted( bool status );

};