1 #ifndef __BTANKS_MRT_TCPSOCKET_H__ 2 #define __BTANKS_MRT_TCPSOCKET_H__ 3 4 /* M-runtime for c++ 5 * Copyright (C) 2005-2008 Vladimir Menshakov 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #include <string> 23 #include "sys_socket.h" 24 #include "export_mrt.h" 25 26 namespace mrt { 27 class Chunk; 28 29 class MRTAPI TCPSocket : public Socket { 30 public: 31 TCPSocket(); 32 33 void noDelay(const bool value = true); 34 35 void listen(const std::string &addr, const unsigned port, const bool reuse = false); 36 void connect(const addr &addr, const bool no_delay = false); 37 void connect(const std::string &host, const int port, const bool no_delay = false); 38 const int send(const void *data, const int len) const; 39 //void send(const mrt::Chunk &data) const; 40 const int recv(void *data, const int len) const; 41 42 void accept(TCPSocket &client); getAddress()43 inline const Socket::addr getAddress() const { return _addr; } 44 private: 45 Socket::addr _addr; 46 }; 47 48 } 49 50 #endif 51 52