owlps/owlps-positioning/src/inputudpsocket.hh

71 lines
1.4 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comté
* (Université de Franche-Comté), France.
*/
#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) ;
/// Reads data & fills the current request
/**
* This function fills the current Request from the data read from
* the input medium.
*
* @returns \em true if #current_request was correctly filled.
* @returns \em false in case of error.
*/
bool fill_current_request(void) ;
//@}
public:
InputUDPSocket(const uint_fast16_t _port) ;
~InputUDPSocket(void) ;
/** @name Read accessors */
//@{
/// Always false
bool eof(void) const ;
//@}
/** @name Operations */
//@{
/// 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_