Platform-independent implementation of the socket interface. More...
#include <src/main/decaf/internal/net/tcp/TcpSocket.h>

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".
| |||||||||||||||||||
| 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.
| |||||||||||||||||||
| 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.
| |||||||||||||||||||
| virtual void | connect (const std::string &hostname, int port, int timeout) | ||||||||||||||||||
Connects this socket to the given host and port.
| |||||||||||||||||||
| 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.
| |||||||||||||||||||
| virtual decaf::io::InputStream * | getInputStream () | ||||||||||||||||||
Gets the InputStream linked to this Socket.
| |||||||||||||||||||
| virtual decaf::io::OutputStream * | getOutputStream () | ||||||||||||||||||
Gets the OutputStream linked to this Socket.
| |||||||||||||||||||
| virtual int | available () | ||||||||||||||||||
Gets the number of bytes that can be read from the Socket without blocking.
| |||||||||||||||||||
| virtual void | close () | ||||||||||||||||||
Closes the socket, terminating any blocked reads or writes.
| |||||||||||||||||||
| 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.
| |||||||||||||||||||
| 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.
| |||||||||||||||||||
| virtual int | getOption (int option) const | ||||||||||||||||||
Gets the specified Socket option.
| |||||||||||||||||||
| virtual void | setOption (int option, int value) | ||||||||||||||||||
Sets the specified option on the Socket if supported.
| |||||||||||||||||||
| 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 | ||||||||||||||||||
Platform-independent implementation of the socket interface.
| decaf::internal::net::tcp::TcpSocket::TcpSocket | ( | ) |
Construct a non-connected socket.
| 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.
| 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.
| 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.
| ipaddress | The address of local ip to bind to. | |
| port | The port number on the host to bind to. |
| 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.
| 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.
| 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. |
| 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.
| 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.
| 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".
Implements decaf::net::SocketImpl.
| virtual int decaf::internal::net::tcp::TcpSocket::getOption | ( | int | option | ) | const [virtual] |
Gets the specified Socket option.
| option | The Socket options whose value is to be retrieved. |
| 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.
| IOException | if an I/O error occurs while attempting this operation. |
Implements decaf::net::SocketImpl.
| bool decaf::internal::net::tcp::TcpSocket::isClosed | ( | ) | const |
| bool decaf::internal::net::tcp::TcpSocket::isConnected | ( | ) | const |
| 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.
| backlog | The maximum length of the connection queue. |
| 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.
| 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. |
| 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.
| option | The Socket option to set. | |
| value | The value of the socket option to apply to the socket. |
| 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.
| 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.
| 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.
| 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. |
| IOException | if an I/O error occurs during the write. | |
| NullPointerException | if buffer is Null. | |
| IndexOutOfBoundsException | if offset + length is greater than buffer size. |
1.6.1