activemq-cpp-3.4.0

decaf::net::SocketImpl Class Reference

Acts as a base class for all physical Socket implementations. More...

#include <src/main/decaf/net/SocketImpl.h>

Inheritance diagram for decaf::net::SocketImpl:

Public Member Functions

 SocketImpl ()
virtual ~SocketImpl ()
virtual void create ()=0
 Creates the underlying platform Socket data structures which allows for Socket options to be applied.
virtual void accept (SocketImpl *socket)=0
 Accepts a new connection on the given Socket.
virtual void connect (const std::string &hostname, int port, int timeout)=0
 Connects this socket to the given host and port.
virtual void bind (const std::string &ipaddress, int port)=0
 Binds this Socket instance to the local ip address and port number given.
virtual void listen (int backlog)=0
 Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.
virtual decaf::io::InputStreamgetInputStream ()=0
 Gets the InputStream linked to this Socket.
virtual decaf::io::OutputStreamgetOutputStream ()=0
 Gets the OutputStream linked to this Socket.
virtual int available ()=0
 Gets the number of bytes that can be read from the Socket without blocking.
virtual void close ()=0
 Closes the socket, terminating any blocked reads or writes.
virtual void shutdownInput ()=0
 Places the input stream for this socket at "end of stream".
virtual void shutdownOutput ()=0
 Disables the output stream for this socket.
virtual int getOption (int option) const =0
 Gets the specified Socket option.
virtual void setOption (int option, int value)=0
 Sets the specified option on the Socket if supported.
int getPort () const
 Gets the port that this socket has been assigned.
int getLocalPort () const
 Gets the value of this SocketImpl's local port field.
std::string getInetAddress () const
 Gets the value of this SocketImpl's address field.
const decaf::io::FileDescriptorgetFileDescriptor () const
 Gets the FileDescriptor for this Socket, the Object is owned by this Socket and should not be deleted by the caller.
virtual std::string getLocalAddress () const =0
 Gets the value of the local Inet address the Socket is bound to if bound, otherwise return the InetAddress ANY value "0.0.0.0".
std::string toString () const
 Returns a string containing the address and port of this Socket instance.
virtual bool supportsUrgentData () const
virtual void sendUrgentData (int data)
 Sends on byte of urgent data to the Socket.

Protected Attributes

int port
 The remote port that this Socket is connected to.
int localPort
 The port on the Local Machine that this Socket is Bound to.
std::string address
 The Remote Address that the Socket is connected to.
io::FileDescriptorfd
 The File Descriptor for this Socket.

Detailed Description

Acts as a base class for all physical Socket implementations.

Since:
1.0

Constructor & Destructor Documentation

decaf::net::SocketImpl::SocketImpl ( )
virtual decaf::net::SocketImpl::~SocketImpl ( ) [virtual]

Member Function Documentation

virtual void decaf::net::SocketImpl::accept ( SocketImpl socket) [pure virtual]

Accepts a new connection on the given Socket.

Parameters:
socketThe accepted connection.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.
SocketExceptionif an error occurs while performing an Accept on the socket.
SocketTimeoutExceptionif the accept call times out due to SO_TIMEOUT being set.
virtual int decaf::net::SocketImpl::available ( ) [pure virtual]

Gets the number of bytes that can be read from the Socket without blocking.

Returns:
the number of bytes that can be read from the Socket without blocking.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::bind ( const std::string &  ipaddress,
int  port 
) [pure virtual]

Binds this Socket instance to the local ip address and port number given.

Parameters:
ipaddressThe address of local ip to bind to.
portThe port number on the host to bind to.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::close ( ) [pure virtual]

Closes the socket, terminating any blocked reads or writes.

Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::connect ( const std::string &  hostname,
int  port,
int  timeout 
) [pure virtual]

Connects this socket to the given host and port.

Parameters:
hostnameThe name of the host to connect to, or IP address.
portThe port number on the host to connect to.
timeoutTime in milliseconds to wait for a connection, 0 indicates forever.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.
SocketTimeoutExceptionif the connect call times out due to timeout being set.
IllegalArguementExceptionif a parameter has an illegal value.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::create ( ) [pure virtual]

Creates the underlying platform Socket data structures which allows for Socket options to be applied.

The created socket is in an unconnected state.

Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

const decaf::io::FileDescriptor* decaf::net::SocketImpl::getFileDescriptor ( ) const [inline]

Gets the FileDescriptor for this Socket, the Object is owned by this Socket and should not be deleted by the caller.

Returns:
a pointer to this Socket's FileDescriptor object.
std::string decaf::net::SocketImpl::getInetAddress ( ) const [inline]

Gets the value of this SocketImpl's address field.

Returns:
the value of the address field.
virtual decaf::io::InputStream* decaf::net::SocketImpl::getInputStream ( ) [pure virtual]

Gets the InputStream linked to this Socket.

Returns:
an InputStream pointer owned by the Socket object.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual std::string decaf::net::SocketImpl::getLocalAddress ( ) const [pure virtual]

Gets the value of the local Inet address the Socket is bound to if bound, otherwise return the InetAddress ANY value "0.0.0.0".

Returns:
the local address bound to, or ANY.

Implemented in decaf::internal::net::tcp::TcpSocket.

int decaf::net::SocketImpl::getLocalPort ( ) const [inline]

Gets the value of this SocketImpl's local port field.

Returns:
the value of localPort.
virtual int decaf::net::SocketImpl::getOption ( int  option) const [pure virtual]

Gets the specified Socket option.

Parameters:
optionThe Socket options whose value is to be retrieved.
Returns:
the value of the given socket option.
Exceptions:
IOExceptionif an I/O error occurs while performing this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual decaf::io::OutputStream* decaf::net::SocketImpl::getOutputStream ( ) [pure virtual]

Gets the OutputStream linked to this Socket.

Returns:
an OutputStream pointer owned by the Socket object.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

int decaf::net::SocketImpl::getPort ( ) const [inline]

Gets the port that this socket has been assigned.

Returns:
the Socket's port number.
virtual void decaf::net::SocketImpl::listen ( int  backlog) [pure virtual]

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

If a connection indication arrives when the queue is full, the connection is refused.

Parameters:
backlogThe maximum length of the connection queue.
Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::sendUrgentData ( int  data) [virtual]

Sends on byte of urgent data to the Socket.

Parameters:
dataThe value to write as urgent data, only the lower eight bits are sent.
Exceptions:
IOExceptionif an I/O error occurs while performing this operation.
virtual void decaf::net::SocketImpl::setOption ( int  option,
int  value 
) [pure virtual]

Sets the specified option on the Socket if supported.

Parameters:
optionThe Socket option to set.
valueThe value of the socket option to apply to the socket.
Exceptions:
IOExceptionif an I/O error occurs while performing this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::shutdownInput ( ) [pure virtual]

Places the input stream for this socket at "end of stream".

Any data sent to this socket is acknowledged and then silently discarded. If you read from a socket input stream after invoking shutdownInput() on the socket, the stream will return EOF.

Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual void decaf::net::SocketImpl::shutdownOutput ( ) [pure virtual]

Disables the output stream for this socket.

For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.

Exceptions:
IOExceptionif an I/O error occurs while attempting this operation.

Implemented in decaf::internal::net::tcp::TcpSocket.

virtual bool decaf::net::SocketImpl::supportsUrgentData ( ) const [inline, virtual]
Returns:
true if this SocketImpl supports sending Urgent Data. The default implementation always returns false.
std::string decaf::net::SocketImpl::toString ( ) const

Returns a string containing the address and port of this Socket instance.

Returns:
a string containing the address and port of this socket.

Field Documentation

std::string decaf::net::SocketImpl::address [protected]

The Remote Address that the Socket is connected to.

The File Descriptor for this Socket.

The port on the Local Machine that this Socket is Bound to.

The remote port that this Socket is connected to.


The documentation for this class was generated from the following file: