00001 //******************************************************************************* 00002 // 00003 // ******* *** *** * 00004 // * * * * 00005 // * * * ***** 00006 // * * *** * * ** * ** *** 00007 // * * * * * * * **** * * * 00008 // * * * * * * * * * * * 00009 // * *** *** * ** ** ** * * 00010 // * 00011 //******************************************************************************* 00012 // see http://sourceforge.net/projects/tcsystem/ for details. 00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 00014 //******************************************************************************* 00015 // 00016 // TCSystem is the legal property of its developers. 00017 // Please refer to the COPYRIGHT file distributed with this source distribution. 00018 // 00019 // This library is free software; you can redistribute it and/or 00020 // modify it under the terms of the GNU Lesser General Public 00021 // License as published by the Free Software Foundation; either 00022 // version 2.1 of the License, or (at your option) any later version. 00023 // 00024 // This library is distributed in the hope that it will be useful, 00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00027 // Lesser General Public License for more details. 00028 // 00029 // You should have received a copy of the GNU Lesser General Public 00030 // License along with this library; if not, write to the Free Software 00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00032 //******************************************************************************* 00033 // $Id: TCNetSocket.h 870 2008-07-21 14:15:33Z the_____tiger $ 00034 //******************************************************************************* 00035 00036 #ifndef _TCNET_SOCKET_H 00037 #define _TCNET_SOCKET_H 00038 00039 #include "TCNetTypes.h" 00040 #include "TCNonCopyable.h" 00041 00042 namespace TC 00043 { 00044 namespace Net 00045 { 00046 class Socket; 00047 00060 typedef SharedPtr<Socket> SocketPtr; 00061 00065 class Socket: protected NonCopyAble 00066 { 00067 public: 00068 virtual ~Socket() {} 00069 00070 virtual bool Open(PortNumber port_number) = 0; 00071 00078 virtual bool Connect(const char* server_name, PortNumber port_number) = 0; 00085 virtual bool Accept(SocketPtr socket) = 0; 00089 virtual bool Close() = 0; 00090 00094 virtual bool IsOpened() const = 0; 00095 00097 virtual PortNumber GetPortNumber() const = 0; 00099 virtual SocketId GetSocket() = 0; 00100 00101 virtual uint32 WriteBytes(uint32 nBytes, const void* bytes) = 0; 00102 virtual uint32 ReadBytes(uint32 nBytes, void *bytes, bool block=true) = 0; 00103 }; 00104 00109 } // namespace Net 00110 } // namespace TC 00111 00112 #endif // _TCNET_SOCKET_H