owlps/owlps-positioning/src/inputudpsocket.hh

57 lines
1.0 KiB
C++

#ifndef _OWLPS_POSITIONING_INPUTUDPSOCKET_HH_
#define _OWLPS_POSITIONING_INPUTUDPSOCKET_HH_
#include "inputmedium.hh"
/// Receives \link Request requests \endlink from a UDP socket
class InputUDPSocket: public InputMedium
{
protected:
int sockfd ;
uint_fast16_t listening_port ;
/** @name Operations */
//@{
/// Initialises the socket
bool init_socket(void) ;
//@}
public:
InputUDPSocket(const uint_fast16_t _port) ;
~InputUDPSocket(void) ;
/** @name Read accessors */
//@{
/// Always false
bool eof(void) const ;
//@}
/** @name Operations */
//@{
/// Reads the next request
const Request& get_next_request(void) ;
/// Closes the socket
bool close_socket(void) ;
//@}
} ;
/* *** Read accessors *** */
/**
* Note that by definition, the end of a socket is never reached.
* @return \em true if the socket is closed.
* @return \em false if the socket is opened.
*/
inline bool InputUDPSocket::eof() const
{
return sockfd < 0 ;
}
#endif // _OWLPS_POSITIONING_INPUTUDPSOCKET_HH_