activemq-cpp-3.6.0
SocketImpl.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_NET_SOCKETIMPL_H_
19 #define _DECAF_NET_SOCKETIMPL_H_
20 
21 #include <decaf/util/Config.h>
22 
23 #include <decaf/io/IOException.h>
24 #include <decaf/io/InputStream.h>
25 #include <decaf/io/OutputStream.h>
27 
31 
32 #include <string>
33 
34 namespace decaf {
35 namespace net {
36 
43  protected:
44 
48  int port;
49 
53  int localPort;
54 
58  std::string address;
59 
64 
65  private:
66 
67  SocketImpl( const SocketImpl& );
68  SocketImpl& operator= ( const SocketImpl& );
69 
70  public:
71 
72  SocketImpl();
73 
74  virtual ~SocketImpl();
75 
76  public:
77 
84  virtual void create() = 0;
85 
96  virtual void accept( SocketImpl* socket ) = 0;
97 
112  virtual void connect( const std::string& hostname, int port, int timeout ) = 0;
113 
124  virtual void bind( const std::string& ipaddress, int port ) = 0;
125 
136  virtual void listen( int backlog ) = 0;
137 
145  virtual decaf::io::InputStream* getInputStream() = 0;
146 
154  virtual decaf::io::OutputStream* getOutputStream() = 0;
155 
163  virtual int available() = 0;
164 
170  virtual void close() = 0;
171 
179  virtual void shutdownInput() = 0;
180 
189  virtual void shutdownOutput() = 0;
190 
201  virtual int getOption( int option ) const = 0;
202 
213  virtual void setOption( int option, int value ) = 0;
214 
220  int getPort() const {
221  return this->port;
222  }
223 
229  int getLocalPort() const {
230  return this->localPort;
231  }
232 
238  std::string getInetAddress() const {
239  return this->address;
240  }
241 
249  return this->fd;
250  }
251 
258  virtual std::string getLocalAddress() const = 0;
259 
265  std::string toString() const;
266 
271  virtual bool supportsUrgentData() const {
272  return false;
273  }
274 
283  virtual void sendUrgentData( int data );
284 
285  };
286 
287 }}
288 
289 #endif /* _DECAF_NET_SOCKETIMPL_H_ */