activemq-cpp-3.9.5
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
24#include <decaf/util/Config.h>
30
31namespace decaf {
32namespace internal {
33namespace net {
34namespace tcp {
35
38 class TcpSocketImpl;
39
43 class DECAF_API TcpSocket: public decaf::net::SocketImpl {
44 private:
45
46 TcpSocketImpl* impl;
47
48 private:
49
50 TcpSocket(const TcpSocket&);
51 TcpSocket& operator=(const TcpSocket&);
52
53 public:
54
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
111
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_*/
int read(unsigned char *buffer, int size, int offset, int length)
Reads the requested data from the Socket and write it into the passed in buffer.
virtual void bind(const std::string &ipaddress, int port)
Binds this Socket instance to the local ip address and port number given.
virtual int available()
Gets the number of bytes that can be read from the Socket without blocking.the number of bytes that c...
virtual std::string getLocalAddress() const
Gets the value of the local Inet address the Socket is bound to if bound, otherwise return the InetAd...
virtual void shutdownOutput()
Disables the output stream for this socket.For a TCP socket, any previously written data will be sent...
virtual void shutdownInput()
Places the input stream for this socket at "end of stream".Any data sent to this socket is acknowledg...
TcpSocket()
Construct a non-connected socket.
virtual int getOption(int option) const
Gets the specified Socket option.the value of the given socket option.
virtual decaf::io::OutputStream * getOutputStream()
Gets the OutputStream linked to this Socket.an OutputStream pointer owned by the Socket object.
virtual decaf::io::InputStream * getInputStream()
Gets the InputStream linked to this Socket.an InputStream pointer owned by the Socket object.
virtual void accept(SocketImpl *socket)
virtual void setOption(int option, int value)
Sets the specified option on the Socket if supported.
virtual void listen(int backlog)
Sets the maximum queue length for incoming connection indications (a request to connect) to the count...
virtual void connect(const std::string &hostname, int port, int timeout)
Connects this socket to the given host and port.
void checkResult(apr_status_t value) const
void write(const unsigned char *buffer, int size, int offset, int length)
Writes the specified data in the passed in buffer to the Socket.
virtual void create()
Creates the underlying platform Socket data structures which allows for Socket options to be applied....
virtual ~TcpSocket()
Releases the socket handle but not gracefully shut down the connection.
virtual void close()
Closes the socket, terminating any blocked reads or writes.
Input stream for performing reads on a socket.
Definition TcpSocketInputStream.h:41
Output stream for performing write operations on a socket.
Definition TcpSocketOutputStream.h:37
A base class that must be implemented by all classes wishing to provide a class that reads in a strea...
Definition InputStream.h:39
Base interface for any class that wants to represent an output stream of bytes.
Definition OutputStream.h:39
Acts as a base class for all physical Socket implementations.
Definition SocketImpl.h:42
int port
The remote port that this Socket is connected to.
Definition SocketImpl.h:48
#define DECAF_API
Definition Config.h:29
Definition TcpSocket.h:34
Definition DefaultServerSocketFactory.h:27
Definition AprPool.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25