activemq-cpp-3.8.2
TcpSocket.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 #ifndef _DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_
18 #define _DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_
19 
21 #include <decaf/net/SocketImpl.h>
22 #include <decaf/io/InputStream.h>
23 #include <decaf/io/OutputStream.h>
24 #include <decaf/util/Config.h>
25 #include <decaf/internal/AprPool.h>
26 #include <decaf/io/IOException.h>
30 
31 namespace decaf {
32 namespace internal {
33 namespace net {
34 namespace tcp {
35 
38  class TcpSocketImpl;
39 
44  private:
45 
46  TcpSocketImpl* impl;
47 
48  private:
49 
50  TcpSocket(const TcpSocket&);
51  TcpSocket& operator=(const TcpSocket&);
52 
53  public:
54 
60  TcpSocket();
61 
65  virtual ~TcpSocket();
66 
70  bool isConnected() const;
71 
75  bool isClosed() const;
76 
80  virtual std::string getLocalAddress() const;
81 
85  virtual void create();
86 
90  virtual void accept(SocketImpl* socket);
91 
95  virtual void bind(const std::string& ipaddress, int port);
96 
100  virtual void connect(const std::string& hostname, int port, int timeout);
101 
105  virtual void listen(int backlog);
106 
110  virtual decaf::io::InputStream* getInputStream();
111 
115  virtual decaf::io::OutputStream* getOutputStream();
116 
120  virtual int available();
121 
125  virtual void close();
126 
130  virtual void shutdownInput();
131 
135  virtual void shutdownOutput();
136 
140  virtual int getOption(int option) const;
141 
145  virtual void setOption(int option, int value);
146 
147  public:
148 
167  int read(unsigned char* buffer, int size, int offset, int length);
168 
185  void write(const unsigned char* buffer, int size, int offset, int length);
186 
187  protected:
188 
189  void checkResult(apr_status_t value) const;
190 
191  };
192 
193 }}}}
194 
195 #endif /*_DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_*/
Platform-independent implementation of the socket interface.
Definition: TcpSocket.h:43
A base class that must be implemented by all classes wishing to provide a class that reads in a strea...
Definition: InputStream.h:39
Acts as a base class for all physical Socket implementations.
Definition: SocketImpl.h:42
Input stream for performing reads on a socket.
Definition: TcpSocketInputStream.h:41
#define DECAF_API
Definition: Config.h:29
Base interface for any class that wants to represent an output stream of bytes.
Definition: OutputStream.h:39
Output stream for performing write operations on a socket.
Definition: TcpSocketOutputStream.h:37
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25