activemq-cpp-3.9.5
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
27
31
32#include <string>
33
34namespace decaf {
35namespace net {
36
42 class DECAF_API SocketImpl : public SocketOptions {
43 protected:
44
48 int port;
49
54
58 std::string address;
59
64
65 private:
66
67 SocketImpl( const SocketImpl& );
68 SocketImpl& operator= ( const SocketImpl& );
69
70 public:
71
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
146
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_ */
This class servers as an opaque wrapper around an underlying OS level resource that can be used as a ...
Definition FileDescriptor.h:32
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
virtual int getOption(int option) const =0
Gets the specified Socket option.
io::FileDescriptor * fd
The File Descriptor for this Socket.
Definition SocketImpl.h:63
virtual void connect(const std::string &hostname, int port, int timeout)=0
Connects this socket to the given host and port.
std::string toString() const
Returns a string containing the address and port of this Socket instance.
std::string address
The Remote Address that the Socket is connected to.
Definition SocketImpl.h:58
int port
The remote port that this Socket is connected to.
Definition SocketImpl.h:48
virtual void bind(const std::string &ipaddress, int port)=0
Binds this Socket instance to the local ip address and port number given.
virtual int available()=0
Gets the number of bytes that can be read from the Socket without blocking.
virtual decaf::io::OutputStream * getOutputStream()=0
Gets the OutputStream linked to this Socket.
int getPort() const
Gets the port that this socket has been assigned.
Definition SocketImpl.h:220
virtual void close()=0
Closes the socket, terminating any blocked reads or writes.
virtual void shutdownOutput()=0
Disables the output stream for this socket.
virtual void create()=0
Creates the underlying platform Socket data structures which allows for Socket options to be applied.
virtual void shutdownInput()=0
Places the input stream for this socket at "end of stream".
std::string getInetAddress() const
Gets the value of this SocketImpl's address field.
Definition SocketImpl.h:238
virtual decaf::io::InputStream * getInputStream()=0
Gets the InputStream linked to this Socket.
virtual void listen(int backlog)=0
Sets the maximum queue length for incoming connection indications (a request to connect) to the count...
int localPort
The port on the Local Machine that this Socket is Bound to.
Definition SocketImpl.h:53
virtual void setOption(int option, int value)=0
Sets the specified option on the Socket if supported.
virtual void accept(SocketImpl *socket)=0
Accepts a new connection on the given Socket.
const decaf::io::FileDescriptor * getFileDescriptor() const
Gets the FileDescriptor for this Socket, the Object is owned by this Socket and should not be deleted...
Definition SocketImpl.h:248
virtual bool supportsUrgentData() const
Definition SocketImpl.h:271
virtual std::string getLocalAddress() const =0
Gets the value of the local Inet address the Socket is bound to if bound, otherwise return the InetAd...
int getLocalPort() const
Gets the value of this SocketImpl's local port field.
Definition SocketImpl.h:229
virtual void sendUrgentData(int data)
Sends on byte of urgent data to the Socket.
Definition SocketOptions.h:30
#define DECAF_API
Definition Config.h:29
Definition URLStreamHandlerManager.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25