/* * This file is part of the Owl Positioning System (OwlPS) project. * It is subject to the copyright notice and license terms in the * COPYRIGHT.t2t file found in the top-level directory of this * distribution and at * https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t * No part of the OwlPS Project, including this file, may be copied, * modified, propagated, or distributed except according to the terms * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be * distributed along with this file, either separately or by replacing * this notice by the COPYRIGHT.t2t file's contents. */ #ifndef _OWLPS_POSITIONING_OUTPUTNETWORKSOCKET_HH_ #define _OWLPS_POSITIONING_OUTPUTNETWORKSOCKET_HH_ #include "outputmedium.hh" #include #include // is not C++ 98 compliant #include #include // for struct sockaddr /// Parent class for all output media that use network sockets class OutputNetworkSocket: public OutputMedium { protected: int sockfd ; std::string remote_host ; uint_fast16_t remote_port ; struct sockaddr server_info ; /** @name Operations */ //@{ /// Initialises the socket /** * You are required to call this function from the constructor of any * derived class. */ virtual bool init_socket(void) = 0 ; /// Sends a string through the socket virtual bool send_data(const std::string &data) const = 0 ; //@} public: OutputNetworkSocket(const std::string &_remote_host, const uint_fast16_t _remote_port): sockfd(-1), remote_host(_remote_host), remote_port(_remote_port) {} ~OutputNetworkSocket(void) ; /** @name Operations */ //@{ /// Sends a list of results through the socket void write(const ResultList &results) ; /// Sends a single result through the socket void write(const Result &result) ; /// Closes the socket bool close_socket(void) ; //@} } ; #endif // _OWLPS_POSITIONING_OUTPUTNETWORKSOCKET_HH_