|
activemq-cpp-3.9.0
|
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. More... | |||||||||||||
| virtual | ~TcpSocket () | ||||||||||||
| Releases the socket handle but not gracefully shut down the connection. More... | |||||||||||||
| 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. More... | |||||||||||||
| void | write (const unsigned char *buffer, int size, int offset, int length) | ||||||||||||
| Writes the specified data in the passed in buffer to the Socket. More... | |||||||||||||
Public Member Functions inherited from decaf::net::SocketImpl | |||||||||||||
| SocketImpl () | |||||||||||||
| virtual | ~SocketImpl () | ||||||||||||
| virtual void | accept (SocketImpl *socket)=0 | ||||||||||||
| Accepts a new connection on the given Socket. More... | |||||||||||||
| int | getPort () const | ||||||||||||
| Gets the port that this socket has been assigned. More... | |||||||||||||
| int | getLocalPort () const | ||||||||||||
| Gets the value of this SocketImpl's local port field. More... | |||||||||||||
| std::string | getInetAddress () const | ||||||||||||
| Gets the value of this SocketImpl's address field. More... | |||||||||||||
| const decaf::io::FileDescriptor * | getFileDescriptor () const | ||||||||||||
| Gets the FileDescriptor for this Socket, the Object is owned by this Socket and should not be deleted by the caller. More... | |||||||||||||
| std::string | toString () const | ||||||||||||
| Returns a string containing the address and port of this Socket instance. More... | |||||||||||||
| virtual bool | supportsUrgentData () const | ||||||||||||
| virtual void | sendUrgentData (int data) | ||||||||||||
| Sends on byte of urgent data to the Socket. More... | |||||||||||||
Public Member Functions inherited from decaf::net::SocketOptions | |||||||||||||
| virtual | ~SocketOptions () | ||||||||||||
Protected Member Functions | |
| void | checkResult (apr_status_t value) const |
Additional Inherited Members | |
Static Public Attributes inherited from decaf::net::SocketOptions | |
| static const int | SOCKET_OPTION_TCP_NODELAY |
| Disable Nagle's algorithm for this connection. More... | |
| static const int | SOCKET_OPTION_BINDADDR |
| Fetch the local address binding of a socket (this option cannot be "set" only "gotten", since sockets are bound at creation time, and so the locally bound address cannot be changed). More... | |
| static const int | SOCKET_OPTION_REUSEADDR |
| Sets SO_REUSEADDR for a socket. More... | |
| static const int | SOCKET_OPTION_BROADCAST |
| Sets SO_BROADCAST for a socket. More... | |
| static const int | SOCKET_OPTION_IP_MULTICAST_IF |
| Set which outgoing interface on which to send multicast packets. More... | |
| static const int | SOCKET_OPTION_IP_MULTICAST_IF2 |
| Same as above. More... | |
| static const int | SOCKET_OPTION_IP_MULTICAST_LOOP |
| This option enables or disables local loopback of multicast datagrams. More... | |
| static const int | SOCKET_OPTION_IP_TOS |
| This option sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket. More... | |
| static const int | SOCKET_OPTION_LINGER |
| Specify a linger-on-close timeout. More... | |
| static const int | SOCKET_OPTION_TIMEOUT |
| Set a timeout on blocking Socket operations. More... | |
| static const int | SOCKET_OPTION_SNDBUF |
| Set a hint the size of the underlying buffers used by the platform for outgoing network I/O. More... | |
| static const int | SOCKET_OPTION_RCVBUF |
| Set a hint the size of the underlying buffers used by the platform for incoming network I/O. More... | |
| static const int | SOCKET_OPTION_KEEPALIVE |
| When the keepalive option is set for a TCP socket and no data has been exchanged across the socket in either direction for 2 hours (NOTE: the actual value is implementation dependent), TCP automatically sends a keepalive probe to the peer. More... | |
| static const int | SOCKET_OPTION_OOBINLINE |
| When the OOBINLINE option is set, any TCP urgent data received on the socket will be received through the socket input stream. More... | |
Protected Attributes inherited from decaf::net::SocketImpl | |
| int | port |
| The remote port that this Socket is connected to. More... | |
| int | localPort |
| The port on the Local Machine that this Socket is Bound to. More... | |
| std::string | address |
| The Remote Address that the Socket is connected to. More... | |
| io::FileDescriptor * | fd |
| The File Descriptor for this Socket. More... | |
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 |
Releases the socket handle but not gracefully shut down the connection.
|
virtual |
|
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 |
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.
|
protected |
|
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 |
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 |
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 |
Gets the InputStream linked to this Socket.
| IOException | if an I/O error occurs while attempting this operation. |
Implements decaf::net::SocketImpl.
|
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 |
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 |
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 |
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 |
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 |
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 |
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. |