00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_
00018 #define _DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_
00019
00020 #include <decaf/net/SocketException.h>
00021 #include <decaf/net/SocketImpl.h>
00022 #include <decaf/io/InputStream.h>
00023 #include <decaf/io/OutputStream.h>
00024 #include <decaf/util/Config.h>
00025 #include <decaf/internal/AprPool.h>
00026 #include <decaf/io/IOException.h>
00027 #include <decaf/net/SocketTimeoutException.h>
00028 #include <decaf/lang/exceptions/NullPointerException.h>
00029 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00030
00031 namespace decaf {
00032 namespace internal {
00033 namespace net {
00034 namespace tcp {
00035
00036 class TcpSocketInputStream;
00037 class TcpSocketOutputStream;
00038 class TcpSocketImpl;
00039
00043 class DECAF_API TcpSocket: public decaf::net::SocketImpl {
00044 private:
00045
00046 TcpSocketImpl* impl;
00047
00048 private:
00049
00050 TcpSocket(const TcpSocket&);
00051 TcpSocket& operator=(const TcpSocket&);
00052
00053 public:
00054
00060 TcpSocket();
00061
00065 virtual ~TcpSocket();
00066
00070 bool isConnected() const;
00071
00075 bool isClosed() const;
00076
00080 virtual std::string getLocalAddress() const;
00081
00085 virtual void create();
00086
00090 virtual void accept(SocketImpl* socket);
00091
00095 virtual void bind(const std::string& ipaddress, int port);
00096
00100 virtual void connect(const std::string& hostname, int port, int timeout);
00101
00105 virtual void listen(int backlog);
00106
00110 virtual decaf::io::InputStream* getInputStream();
00111
00115 virtual decaf::io::OutputStream* getOutputStream();
00116
00120 virtual int available();
00121
00125 virtual void close();
00126
00130 virtual void shutdownInput();
00131
00135 virtual void shutdownOutput();
00136
00140 virtual int getOption(int option) const;
00141
00145 virtual void setOption(int option, int value);
00146
00147 public:
00148
00167 int read(unsigned char* buffer, int size, int offset, int length);
00168
00185 void write(const unsigned char* buffer, int size, int offset, int length);
00186
00187 protected:
00188
00189 void checkResult(apr_status_t value) const;
00190
00191 };
00192
00193 }}}}
00194
00195 #endif