decaf::internal::net::tcp::TcpSocket Class Reference

Platform-independent implementation of the socket interface. More...

#include <src/main/decaf/internal/net/tcp/TcpSocket.h>

Inheritance diagram for decaf::internal::net::tcp::TcpSocket:
Inheritance graph
[legend]

Public Member Functions

 TcpSocket ()
 Construct a non-connected socket.
virtual ~TcpSocket ()
 Releases the socket handle but not gracefully shut down the connection.
bool isConnected () const
bool isClosed () const
virtual std::string getLocalAddress () const
 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.

virtual void create ()
 Creates the underlying platform Socket data structures which allows for Socket options to be applied.The created socket is in an unconnected state.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual void accept (SocketImpl *socket)
 
virtual void bind (const std::string &ipaddress, int port)
 Binds this Socket instance to the local ip address and port number given.
Parameters:
ipaddress The address of local ip to bind to.
port The port number on the host to bind to.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual void connect (const std::string &hostname, int port, int timeout)
 Connects this socket to the given host and port.
Parameters:
hostname The name of the host to connect to, or IP address.
port The port number on the host to connect to.
timeout Time in milliseconds to wait for a connection, 0 indicates forever.
Exceptions:
IOException if an I/O error occurs while attempting this operation.
SocketTimeoutException if the connect call times out due to timeout being set.
IllegalArguementException if a parameter has an illegal value.

virtual void listen (int backlog)
 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:
backlog The maximum length of the connection queue.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual decaf::io::InputStreamgetInputStream ()
 Gets the InputStream linked to this Socket.
Returns:
an InputStream pointer owned by the Socket object.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual decaf::io::OutputStreamgetOutputStream ()
 Gets the OutputStream linked to this Socket.
Returns:
an OutputStream pointer owned by the Socket object.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual int available ()
 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:
IOException if an I/O error occurs while attempting this operation.

virtual void close ()
 Closes the socket, terminating any blocked reads or writes.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

virtual void shutdownInput ()
 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:
IOException if an I/O error occurs while attempting this operation.

virtual void shutdownOutput ()
 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:
IOException if an I/O error occurs while attempting this operation.

virtual int getOption (int option) const
 Gets the specified Socket option.
Parameters:
option The Socket options whose value is to be retrieved.
Returns:
the value of the given socket option.
Exceptions:
IOException if an I/O error occurs while performing this operation.

virtual void setOption (int option, int value)
 Sets the specified option on the Socket if supported.
Parameters:
option The Socket option to set.
value The value of the socket option to apply to the socket.
Exceptions:
IOException if an I/O error occurs while performing this operation.

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.
void write (const unsigned char *buffer, int size, int offset, int length)
 Writes the specified data in the passed in buffer to the Socket.

Protected Member Functions

void checkResult (apr_status_t value) const

Detailed Description

Platform-independent implementation of the socket interface.


Constructor & Destructor Documentation

decaf::internal::net::tcp::TcpSocket::TcpSocket (  ) 

Construct a non-connected socket.

Exceptions:
SocketException thrown if an error occurs while creating the Socket.
virtual decaf::internal::net::tcp::TcpSocket::~TcpSocket (  )  [virtual]

Releases the socket handle but not gracefully shut down the connection.


Member Function Documentation

virtual void decaf::internal::net::tcp::TcpSocket::accept ( SocketImpl *  socket  )  [virtual]

virtual int decaf::internal::net::tcp::TcpSocket::available (  )  [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:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

virtual void decaf::internal::net::tcp::TcpSocket::bind ( const std::string &  ipaddress,
int  port 
) [virtual]

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

Parameters:
ipaddress The address of local ip to bind to.
port The port number on the host to bind to.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

void decaf::internal::net::tcp::TcpSocket::checkResult ( apr_status_t  value  )  const [protected]
virtual void decaf::internal::net::tcp::TcpSocket::close (  )  [virtual]

Closes the socket, terminating any blocked reads or writes.

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

Implements decaf::net::SocketImpl.

virtual void decaf::internal::net::tcp::TcpSocket::connect ( const std::string &  hostname,
int  port,
int  timeout 
) [virtual]

Connects this socket to the given host and port.

Parameters:
hostname The name of the host to connect to, or IP address.
port The port number on the host to connect to.
timeout Time in milliseconds to wait for a connection, 0 indicates forever.
Exceptions:
IOException if an I/O error occurs while attempting this operation.
SocketTimeoutException if the connect call times out due to timeout being set.
IllegalArguementException if a parameter has an illegal value.

Implements decaf::net::SocketImpl.

virtual void decaf::internal::net::tcp::TcpSocket::create (  )  [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:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

virtual decaf::io::InputStream* decaf::internal::net::tcp::TcpSocket::getInputStream (  )  [virtual]

Gets the InputStream linked to this Socket.

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

Implements decaf::net::SocketImpl.

virtual std::string decaf::internal::net::tcp::TcpSocket::getLocalAddress (  )  const [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.

Implements decaf::net::SocketImpl.

virtual int decaf::internal::net::tcp::TcpSocket::getOption ( int  option  )  const [virtual]

Gets the specified Socket option.

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

Implements decaf::net::SocketImpl.

virtual decaf::io::OutputStream* decaf::internal::net::tcp::TcpSocket::getOutputStream (  )  [virtual]

Gets the OutputStream linked to this Socket.

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

Implements decaf::net::SocketImpl.

bool decaf::internal::net::tcp::TcpSocket::isClosed (  )  const
Returns:
true if the close method has been called on this Socket.
bool decaf::internal::net::tcp::TcpSocket::isConnected (  )  const
Returns:
true if the socketHandle is not in a disconnected state.
virtual void decaf::internal::net::tcp::TcpSocket::listen ( int  backlog  )  [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:
backlog The maximum length of the connection queue.
Exceptions:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

int decaf::internal::net::tcp::TcpSocket::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.

Parameters:
buffer The buffer to read into
size The size of the specified buffer
offset The offset into the buffer where reading should start filling.
length The number of bytes past offset to fill with data.
Returns:
the actual number of bytes read or -1 if at EOF.
Exceptions:
IOException if an I/O error occurs during the read.
NullPointerException if buffer is Null.
IndexOutOfBoundsException if offset + length is greater than buffer size.
virtual void decaf::internal::net::tcp::TcpSocket::setOption ( int  option,
int  value 
) [virtual]

Sets the specified option on the Socket if supported.

Parameters:
option The Socket option to set.
value The value of the socket option to apply to the socket.
Exceptions:
IOException if an I/O error occurs while performing this operation.

Implements decaf::net::SocketImpl.

virtual void decaf::internal::net::tcp::TcpSocket::shutdownInput (  )  [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:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

virtual void decaf::internal::net::tcp::TcpSocket::shutdownOutput (  )  [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:
IOException if an I/O error occurs while attempting this operation.

Implements decaf::net::SocketImpl.

void decaf::internal::net::tcp::TcpSocket::write ( const unsigned char *  buffer,
int  size,
int  offset,
int  length 
)

Writes the specified data in the passed in buffer to the Socket.

Parameters:
buffer The buffer to write to the socket.
size The size of the specified buffer.
offset The offset into the buffer where the data to write starts at.
length The number of bytes past offset to write.
Exceptions:
IOException if an I/O error occurs during the write.
NullPointerException if buffer is Null.
IndexOutOfBoundsException if offset + length is greater than buffer size.

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

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1