#include <lliosocket.h>
Public Types | |
| enum | EType { STREAM_TCP, DATAGRAM_UDP } |
| Type of socket to create. More... | |
| enum | { PORT_INVALID = (U16)-1, PORT_EPHEMERAL = 0 } |
| Anonymous enumeration to help identify ports. More... | |
| typedef boost::shared_ptr < LLSocket > | ptr_t |
| Reference counted shared pointers to sockets. | |
Public Member Functions | |
| bool | blockingConnect (const LLHost &host) |
| Perform a blocking connect to a host. Do not use in production. | |
| U16 | getPort () const |
| Get the type of socket. | |
| apr_socket_t * | getSocket () const |
| Get the apr socket implementation. | |
| ~LLSocket () | |
| Do not call this directly. | |
Static Public Member Functions | |
| static ptr_t | create (apr_pool_t *pool, EType type, U16 port=PORT_EPHEMERAL) |
| Create a socket. | |
| static ptr_t | create (apr_socket_t *socket, apr_pool_t *pool) |
| Create a LLSocket when you already have an apr socket. | |
Protected Member Functions | |
| LLSocket (apr_socket_t *socket, apr_pool_t *pool) | |
Protected constructor since should only make sockets with one of the two create() calls. | |
| void | setOptions () |
| Set default socket options. | |
Protected Attributes | |
| apr_socket_t * | mSocket |
| apr_pool_t * | mPool |
| U16 | mPort |
An instance of this class represents a single socket over it's entire life - from uninitialized, to connected, to a listening socket depending on it's purpose. This class simplifies our access into the socket interface by only providing stream/tcp and datagram/udp sockets - the only types we are interested in, since those are the only properly supported by all of our platforms.
Definition at line 63 of file lliosocket.h.
| typedef boost::shared_ptr<LLSocket> LLSocket::ptr_t |
| enum LLSocket::EType |
| anonymous enum |
| LLSocket::LLSocket | ( | apr_socket_t * | socket, | |
| apr_pool_t * | pool | |||
| ) | [protected] |
Protected constructor since should only make sockets with one of the two create() calls.
Definition at line 242 of file lliosocket.cpp.
References ll_debug_socket(), mSocket, and LLMemType::MTYPE_IO_TCP.
Referenced by create().


| LLSocket::~LLSocket | ( | ) |
Do not call this directly.
Definition at line 251 of file lliosocket.cpp.
References ll_debug_socket(), mPool, mSocket, and LLMemType::MTYPE_IO_TCP.

| LLSocket::ptr_t LLSocket::create | ( | apr_pool_t * | pool, | |
| EType | type, | |||
| U16 | port = PORT_EPHEMERAL | |||
| ) | [static] |
Create a socket.
This is the call you would use if you intend to create a listen socket. If you intend the socket to be known to external clients without prior port notification, do not use PORT_EPHEMERAL.
| pool | The apr pool to use. A child pool will be created and associated with the socket. | |
| type | The type of socket to create | |
| port | The port for the socket |
Definition at line 106 of file lliosocket.cpp.
References DATAGRAM_UDP, ll_apr_warn_status(), LL_DEFAULT_LISTEN_BACKLOG, lldebugs, llendl, LLSocket(), LLMemType::MTYPE_IO_TCP, NULL, PORT_EPHEMERAL, indra::ipc::saranwrap::status(), and STREAM_TCP.
Referenced by LLIOHTTPServer::create(), tut::pipe_and_pump_fitness::pipe_and_pump_fitness(), LLIOServerSocket::process_impl(), and LLVoiceClient::stateMachine().


| LLSocket::ptr_t LLSocket::create | ( | apr_socket_t * | socket, | |
| apr_pool_t * | pool | |||
| ) | [static] |
Create a LLSocket when you already have an apr socket.
This method assumes an ephemeral port. This is typically used by calls which spawn a socket such as a call to accept() as in the server socket. This call should not fail if you have a valid apr socket. Because of the nature of how accept() works, you are expected to create a new pool for the socket, use that pool for the accept, and pass it in here where it will be bound with the socket and destroyed at the same time.
| socket | The apr socket to use | |
| pool | The pool used to create the socket. *NOTE: The pool passed in will be DESTROYED. |
Definition at line 204 of file lliosocket.cpp.
References LLSocket(), LLMemType::MTYPE_IO_TCP, and PORT_EPHEMERAL.

| bool LLSocket::blockingConnect | ( | const LLHost & | host | ) |
Perform a blocking connect to a host. Do not use in production.
| host | The host to connect this socket to. |
Definition at line 219 of file lliosocket.cpp.
References LLHost::getIPString(), LLHost::getPort(), ll_apr_warn_status(), ll_debug_socket(), MAXADDRSTR, mPool, mSocket, NULL, and setOptions().

| U16 LLSocket::getPort | ( | ) | const [inline] |
Get the type of socket.
Get the port. This will return PORT_EPHEMERAL if bind was never called.
Definition at line 144 of file lliosocket.h.
References mPort.
| apr_socket_t* LLSocket::getSocket | ( | ) | const [inline] |
Get the apr socket implementation.
Definition at line 151 of file lliosocket.h.
References mSocket.
| void LLSocket::setOptions | ( | ) | [protected] |
Set default socket options.
Definition at line 266 of file lliosocket.cpp.
References ll_apr_warn_status(), LL_RECV_BUFFER_SIZE, LL_SEND_BUFFER_SIZE, mSocket, and LLMemType::MTYPE_IO_TCP.
Referenced by blockingConnect().


apr_socket_t* LLSocket::mSocket [protected] |
Definition at line 173 of file lliosocket.h.
Referenced by blockingConnect(), getSocket(), LLSocket(), setOptions(), and ~LLSocket().
apr_pool_t* LLSocket::mPool [protected] |
U16 LLSocket::mPort [protected] |
1.5.5