ENUt
|
00001 /* 00002 00003 This file is a part of ENUt, a library containing network 00004 programming utilities. 00005 00006 Copyright (C) 2006-2008 Hasselt University - Expertise Centre for 00007 Digital Media (EDM) (http://www.edm.uhasselt.be) 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00022 USA 00023 00024 */ 00025 00030 #ifndef NUT_TCPSOCKET_H 00031 00032 #define NUT_TCPSOCKET_H 00033 00034 #include "nutconfig.h" 00035 #include "nuttypes.h" 00036 #include "socket.h" 00037 #include "networklayeraddress.h" 00038 00039 namespace nut 00040 { 00041 00043 class ENUT_IMPORTEXPORT TCPSocket : public Socket 00044 { 00045 protected: 00046 TCPSocket(NetworkLayerProtocol proto) { m_protocol = proto; } 00047 TCPSocket(const std::string &objName, NetworkLayerProtocol proto) : Socket(objName) 00048 { m_protocol = proto; } 00049 public: 00050 virtual ~TCPSocket() { } 00051 00053 NetworkLayerProtocol getProtocol() const { return m_protocol; } 00054 00059 virtual bool create(uint16_t portNumber = 0) = 0; 00060 00066 virtual bool create(const NetworkLayerAddress &bindAddress, uint16_t portNumber = 0) = 0; 00067 00069 virtual bool destroy() = 0; 00070 00072 virtual bool setNonBlocking(bool f = true) = 0; 00073 00075 virtual uint16_t getLocalPortNumber() = 0; 00076 00082 virtual bool connect(const NetworkLayerAddress &hostAddress, uint16_t portNumber) = 0; 00083 00088 virtual bool listen(int backlog) = 0; 00089 00094 virtual bool accept(TCPSocket **pNewSock) = 0; 00095 00097 virtual bool isConnected() = 0; 00098 00102 virtual const NetworkLayerAddress *getDestinationAddress() const = 0; 00103 00105 virtual uint16_t getDestinationPort() const = 0; 00106 00115 virtual bool write(const void *pData, size_t &length) = 0; 00116 00118 virtual bool getAvailableDataLength(size_t &length) = 0; 00119 00128 virtual bool read(void *pBuffer, size_t &bufferSize) = 0; 00129 private: 00130 NetworkLayerProtocol m_protocol; 00131 00132 friend class TCPPacketSocket; 00133 }; 00134 00135 } 00136 00137 #endif // NUT_TCPSOCKET_H 00138