StreamSocket.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_StreamSocket_hxx
00024 #define __ccxx_StreamSocket_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/IOException.h++>
00028 #include <commonc++/Socket.h++>
00029 #include <commonc++/Stream.h++>
00030 
00031 namespace ccxx {
00032 
00038 class COMMONCPP_API StreamSocket : public Stream, public Socket
00039 {
00040   friend class ServerSocket;
00041 
00042   public:
00043 
00049   StreamSocket(uint16_t port = 0) throw();
00050 
00052   ~StreamSocket() throw();
00053 
00054   void connect(const String &addr, uint16_t port) throw(IOException);
00055   void connect(const SocketAddress &addr) throw(IOException);
00056 
00057   size_t read(byte_t *buffer, size_t buflen) throw(IOException);
00058   size_t write(const byte_t *buffer, size_t buflen) throw(IOException);
00059 
00060   inline size_t read(ByteBuffer& buffer) throw(IOException)
00061   { return(Stream::read(buffer)); }
00062   inline size_t write(ByteBuffer& buffer) throw(IOException)
00063   { return(Stream::write(buffer)); }
00064 
00065   inline size_t read(CharBuffer& buffer) throw(IOException)
00066   { return(Stream::read(buffer)); }
00067   inline size_t write(CharBuffer& buffer) throw(IOException)
00068   { return(Stream::write(buffer)); }
00069 
00070   inline size_t read(byte_t *buffer, size_t buflen, int64_t offset,
00071                      AsyncIOTask &task) throw(IOException)
00072   { return(Stream::read(buffer, buflen, offset, task)); }
00073   inline size_t write(const byte_t *buffer, size_t buflen, int64_t offset,
00074                       AsyncIOTask &task) throw(IOException)
00075   { return(Stream::write(buffer, buflen, offset, task)); }
00076 
00077   inline size_t read(ByteBuffer &buffer, int64_t offset, AsyncIOTask &task)
00078     throw(IOException)
00079   { return(Stream::read(buffer, offset, task)); }
00080   inline size_t write(ByteBuffer &buffer, int64_t offset, AsyncIOTask &task)
00081     throw(IOException)
00082   { return(Stream::write(buffer, offset, task)); }
00083 
00084   size_t read(MemoryBlock *vec, uint_t count) throw(IOException);
00085   size_t write(const MemoryBlock *vec, uint_t count) throw(IOException);
00086 
00092   byte_t readOOB() throw(IOException);
00093 
00099   void writeOOB(byte_t data) throw(IOException);
00100 
00101   void close(IOMode mode = IOReadWrite) throw();
00102   virtual void shutdown() throw();
00103 
00104   void setTimeout(timespan_ms_t timeout) throw(IOException);
00105 
00106   private:
00107 
00108   void setSocketHandle(SocketHandle handle);
00109 
00110   CCXX_COPY_DECLS(StreamSocket);
00111 };
00112 
00113 }; // namespace ccxx
00114 
00115 #endif // __ccxx_StreamSocket_hxx
00116 
00117 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3