StreamSocket.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 };
00114
00115 #endif // __ccxx_StreamSocket_hxx
00116
00117