00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_NET_SOCKETIMPL_H_ 00019 #define _DECAF_NET_SOCKETIMPL_H_ 00020 00021 #include <decaf/util/Config.h> 00022 00023 #include <decaf/io/IOException.h> 00024 #include <decaf/io/InputStream.h> 00025 #include <decaf/io/OutputStream.h> 00026 #include <decaf/io/FileDescriptor.h> 00027 00028 #include <decaf/net/SocketException.h> 00029 #include <decaf/net/SocketTimeoutException.h> 00030 #include <decaf/net/SocketOptions.h> 00031 00032 #include <string> 00033 00034 namespace decaf { 00035 namespace net { 00036 00042 class DECAF_API SocketImpl : public SocketOptions { 00043 protected: 00044 00048 int port; 00049 00053 int localPort; 00054 00058 std::string address; 00059 00063 io::FileDescriptor* fd; 00064 00065 private: 00066 00067 SocketImpl( const SocketImpl& ); 00068 SocketImpl& operator= ( const SocketImpl& ); 00069 00070 public: 00071 00072 SocketImpl(); 00073 00074 virtual ~SocketImpl(); 00075 00076 public: 00077 00084 virtual void create() = 0; 00085 00096 virtual void accept( SocketImpl* socket ) = 0; 00097 00112 virtual void connect( const std::string& hostname, int port, int timeout ) = 0; 00113 00124 virtual void bind( const std::string& ipaddress, int port ) = 0; 00125 00136 virtual void listen( int backlog ) = 0; 00137 00145 virtual decaf::io::InputStream* getInputStream() = 0; 00146 00154 virtual decaf::io::OutputStream* getOutputStream() = 0; 00155 00163 virtual int available() = 0; 00164 00170 virtual void close() = 0; 00171 00179 virtual void shutdownInput() = 0; 00180 00189 virtual void shutdownOutput() = 0; 00190 00201 virtual int getOption( int option ) const = 0; 00202 00213 virtual void setOption( int option, int value ) = 0; 00214 00220 int getPort() const { 00221 return this->port; 00222 } 00223 00229 int getLocalPort() const { 00230 return this->localPort; 00231 } 00232 00238 std::string getInetAddress() const { 00239 return this->address; 00240 } 00241 00248 const decaf::io::FileDescriptor* getFileDescriptor() const { 00249 return this->fd; 00250 } 00251 00258 virtual std::string getLocalAddress() const = 0; 00259 00265 std::string toString() const; 00266 00271 virtual bool supportsUrgentData() const { 00272 return false; 00273 } 00274 00283 virtual void sendUrgentData( int data ); 00284 00285 }; 00286 00287 }} 00288 00289 #endif /* _DECAF_NET_SOCKETIMPL_H_ */
1.6.1