giuliomoro@44: /* giuliomoro@44: * udpServer.h giuliomoro@44: * giuliomoro@44: * Created on: 19 May 2015 giuliomoro@44: * Author: giulio moro giuliomoro@44: */ giuliomoro@44: giuliomoro@44: #ifndef UDPSERVER_H_ giuliomoro@44: #define UDPSERVER_H_ giuliomoro@44: giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: #include giuliomoro@44: giuliomoro@44: class UdpServer{ giuliomoro@44: private: giuliomoro@44: int port; giuliomoro@44: int enabled; giuliomoro@44: int inSocket; giuliomoro@44: struct sockaddr_in server; giuliomoro@44: struct timeval stTimeOut; giuliomoro@44: fd_set stReadFDS; giuliomoro@44: int size; giuliomoro@44: void *wasteBuffer; giuliomoro@44: int wasteBufferSize; giuliomoro@44: int length; giuliomoro@44: socklen_t fromLength; giuliomoro@44: struct sockaddr_in from; giuliomoro@44: public: giuliomoro@44: UdpServer(); giuliomoro@44: UdpServer(int aPort); giuliomoro@44: ~UdpServer(); giuliomoro@44: bool init(int aPort); giuliomoro@44: bool bindToPort(int aPort); giuliomoro@44: int getBoundPort() const; giuliomoro@44: int read(void *destBuffer, giuliomoro@44: int maxBytesToRead); giuliomoro@44: int emptySocket(); giuliomoro@44: int emptySocket(int maxBytes); giuliomoro@44: void *getWaste(); giuliomoro@44: }; giuliomoro@44: giuliomoro@44: giuliomoro@44: giuliomoro@44: #endif /* UDPSERVER_H_ */