Made to Order Software Corporation Logo

LLChatLib: LLSocket Class Reference

LLSocket Class Reference

Implementation of a wrapper around a socket. More...

#include <lliosocket.h>

List of all members.

Public Types

enum  
 

Anonymous enumeration to help identify ports.



enum  EType
 

Type of socket to create.



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_socket_t *socket, apr_pool_t *pool)
 Create a LLSocket when you already have an apr socket.

static ptr_t create (apr_pool_t *pool, EType type, U16 port=PORT_EPHEMERAL)
 Create a 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.


Detailed Description

Implementation of a wrapper around a socket.

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.


Member Function Documentation

bool LLSocket::blockingConnect ( const LLHost &  host  ) 

Perform a blocking connect to a host. Do not use in production.

Parameters:
host The host to connect this socket to.
Returns:
Returns true if the connect was successful.

Here is the call graph for this function:

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.

Parameters:
socket The apr socket to use
pool The pool used to create the socket. *NOTE: The pool passed in will be DESTROYED.
Returns:
A valid socket shared pointer if the call worked.

Here is the call graph for this function:

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.

Parameters:
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
Returns:
A valid socket shared pointer if the call worked.

LLSocket

Here is the call graph for this function:

U16 LLSocket::getPort (  )  const [inline]

Get the type of socket.

Get the port. This will return PORT_EPHEMERAL if bind was never called.

Returns:
Returns the port associated with this socket.
apr_socket_t* LLSocket::getSocket (  )  const [inline]

Get the apr socket implementation.

Returns:
Returns the raw apr socket.

The documentation for this class was generated from the following files:
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llmessage/lliosocket.h
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llmessage/lliosocket.cpp
Generated on Thu Sep 23 17:18:46 2010 for LLChatLib by  doxygen 1.6.3