/* * SocketClient.h Created on: 2 Jul 2014 * Copyright (c) 2014 Derek Molloy (www.derekmolloy.ie) * Made available for the book "Exploring BeagleBone" * See: www.exploringbeaglebone.com * Licensed under the EUPL V.1.1 * * This Software is provided to You under the terms of the European * Union Public License (the "EUPL") version 1.1 as published by the * European Union. Any use of this Software, other than as authorized * under this License is strictly prohibited (to the extent such use * is covered by a right of the copyright holder of this Software). * * This Software is provided under the License on an "AS IS" basis and * without warranties of any kind concerning the Software, including * without limitation merchantability, fitness for a particular purpose, * absence of defects or errors, accuracy, and non-infringement of * intellectual property rights other than copyright. This disclaimer * of warranty is an essential part of the License and a condition for * the grant of any rights to this Software. * * For more details, see http://www.derekmolloy.ie/ */ #ifndef SOCKETCLIENT_H_ #define SOCKETCLIENT_H_ #include #include #include #include #include namespace exploringBB { /** * @class SocketClient * @brief A class that encapsulates a socket client to be used for network communication */ class SocketClient { private: int socketfd; struct sockaddr_in serverAddress; struct hostent *server; std::string serverName; int portNumber; bool isConnected; public: SocketClient(std::string serverName, int portNumber); virtual int connectToServer(); virtual int disconnectFromServer(); virtual int send(std::string message); virtual std::string receive(int size); //virtual std::string receiveAll(); bool isClientConnected() { return this->isConnected; } virtual ~SocketClient(); }; } /* namespace exploringBB */ #endif /* SOCKETCLIENT_H_ */