conexus logo

Conexus::NSPR::Socket Class Reference
[Conexus I/O Endpoints with NSPR supportConexus I/O Endpoints]

This class encapsulates NSPR's Socket API and serves as the base class for all objects performing socket I/O. More...

#include <socket.h>

Inheritance diagram for Conexus::NSPR::Socket:

Inheritance graph
[legend]

List of all members.

Public Types

typedef ConexusPointer< Socketpointer

Public Member Functions

virtual ~Socket () throw ()
virtual void close (bool force=false) throw ( close_exception )
 Overloads the parent FileDescriptor class to ensure that the final state clears the BOUND, CONNECTED, LISTENING and ACCEPTED flags.
virtual void bind () throw ( bind_exception )
 Binding without an address (autobinding) is a child specific action.
virtual void bind (const Conexus::Address &a) throw ( bind_exception )
 Binds the socket to the provided address.
virtual void connect () throw ( connect_exception )
 Connecting without an address (autoconnecting) is a child specific action.
virtual void connect (const Address &a) throw ( connect_exception )
 Connects the socket to the provided address.
virtual void listen (int backlog=0)
 Places the socket in a listening mode; nearly identical to calling listen() on the socket.
virtual ssize_t writeto (Address &a, const Data data) throw (write_exception)
virtual void set_option (PRSocketOptionData &option)
virtual void change_state (long states) throw ( state_exception )
sigc::signal< void > signal_bound ()
sigc::signal< void > signal_connected ()
sigc::signal< void > signal_listening ()
bool is_bound ()
bool is_connected ()
bool is_listening ()
bool is_accepted ()
bool set_non_blocking (bool set=true)
bool is_non_blocking ()
virtual Conexus::IPv4::Addresslocal_address ()
virtual Conexus::IPv4::Addressremote_address ()
virtual void set_remote_address (Conexus::IPv4::Address addr)
virtual void unset_remote_address ()
virtual void set_local_address (Conexus::IPv4::Address addr)

Protected Member Functions

 Socket () throw ()
virtual size_t write_data (const Data data, Timeout timeout) throw ( write_exception )
virtual Data read_data (size_t s, Timeout timeout) throw ( read_exception )
 Reimplements Conexus::Endpoint::read_data() using Conexus::NSPR::FileDescriptor::read_data().
virtual void set_state_closed ()
virtual void set_state_bound ()
virtual void set_state_connected ()
virtual void set_state_listening ()
virtual void on_local_address_changed ()
virtual void on_remote_address_changed ()
void on_local_address_changed_proxy ()
void on_remote_address_changed_proxy ()

Protected Attributes

Conexus::IPv4::Address m_local_address
Conexus::IPv4::Address m_remote_address
bool m_remote_address_set
bool m_non_blocking
sigc::signal< void > m_signal_bound
sigc::signal< void > m_signal_connected
sigc::signal< void > m_signal_listening

Friends

class Conexus::NSS::SSLSocket


Detailed Description

This class encapsulates NSPR's Socket API and serves as the base class for all objects performing socket I/O.

This class provides the following propertymm properties:

Author:
Rick L Vinyard Jr

Member Typedef Documentation

typedef ConexusPointer<Socket> Conexus::NSPR::Socket::pointer


Constructor & Destructor Documentation

Conexus::NSPR::Socket::Socket (  )  throw () [protected]

Conexus::NSPR::Socket::~Socket (  )  throw () [virtual]


Member Function Documentation

void Conexus::NSPR::Socket::bind ( const Conexus::Address a  )  throw ( bind_exception ) [virtual]

Binds the socket to the provided address.

The socket should already be in the OPENED state before this call.

If the socket is in the CLOSED state, then set_state(OPENED) will be automatically called.

References Conexus::NSPR::addr_to_nspr(), and Conexus::ENDPOINT_OPENED.

void Conexus::NSPR::Socket::bind (  )  throw ( bind_exception ) [virtual]

Binding without an address (autobinding) is a child specific action.

By default an attempt to bind without providing an address will result in a thrown exception condition. Therefore children should modify this behavior if they wish to provide autobinding.

Reimplemented in Conexus::NSPR::UDP.

References m_local_address.

Referenced by Conexus::NSPR::UDP::bind().

void Conexus::NSPR::Socket::change_state ( long  states  )  throw ( state_exception ) [virtual]

void Conexus::NSPR::Socket::close ( bool  force = false  )  throw ( close_exception ) [virtual]

Overloads the parent FileDescriptor class to ensure that the final state clears the BOUND, CONNECTED, LISTENING and ACCEPTED flags.

Reimplemented from Conexus::NSPR::FileDescriptor.

void Conexus::NSPR::Socket::connect ( const Address a  )  throw ( connect_exception ) [virtual]

Connects the socket to the provided address.

If the socket is in the CLOSED state, then set_state(OPENED) will be automatically called.

If the provided address is a broadcast address, will also set the broadcast socket option.

References Conexus::NSPR::addr_to_nspr(), and Conexus::ENDPOINT_OPENED.

void Conexus::NSPR::Socket::connect (  )  throw ( connect_exception ) [virtual]

Connecting without an address (autoconnecting) is a child specific action.

By default an attempt to connect without providing an address will result in a thrown exception condition. Therefore children should modify this behavior if they wish to provide autoconnection.

Reimplemented in Conexus::NSPR::TCP, and Conexus::NSPR::UDP.

Referenced by Conexus::NSPR::UDP::connect(), and Conexus::NSPR::TCP::connect().

bool Conexus::NSPR::Socket::is_accepted (  ) 

bool Conexus::NSPR::Socket::is_bound (  ) 

bool Conexus::NSPR::Socket::is_connected (  ) 

bool Conexus::NSPR::Socket::is_listening (  ) 

bool Conexus::NSPR::Socket::is_non_blocking (  ) 

void Conexus::NSPR::Socket::listen ( int  backlog = 0  )  [virtual]

Places the socket in a listening mode; nearly identical to calling listen() on the socket.

The socket should already be in the BOUND state before this call.

If the socket is in the CLOSED or OPENED states, then set_state(BOUND) will be automatically called.

References change_state(), is_bound(), Conexus::NSPR::FileDescriptor::m_fd, set_state_listening(), and Conexus::SOCKET_BOUND.

Conexus::IPv4::Address & Conexus::NSPR::Socket::local_address (  )  [virtual]

References m_local_address.

void Conexus::NSPR::Socket::on_local_address_changed (  )  [protected, virtual]

Reimplemented in Conexus::NSPR::TCP.

Referenced by on_local_address_changed_proxy().

void Conexus::NSPR::Socket::on_local_address_changed_proxy (  )  [protected]

References on_local_address_changed().

Referenced by Socket().

void Conexus::NSPR::Socket::on_remote_address_changed (  )  [protected, virtual]

Reimplemented in Conexus::NSPR::TCP.

Referenced by on_remote_address_changed_proxy().

void Conexus::NSPR::Socket::on_remote_address_changed_proxy (  )  [protected]

Data Conexus::NSPR::Socket::read_data ( size_t  s,
Timeout  timeout 
) throw ( read_exception ) [protected, virtual]

Reimplements Conexus::Endpoint::read_data() using Conexus::NSPR::FileDescriptor::read_data().

Changes from FileDescriptor::read_data()

Reimplemented from Conexus::NSPR::FileDescriptor.

References Conexus::NSPR::FileDescriptor::read_data(), Conexus::Data::size(), and Conexus::SOCKET_BOUND.

Conexus::IPv4::Address & Conexus::NSPR::Socket::remote_address (  )  [virtual]

References m_remote_address.

void Conexus::NSPR::Socket::set_local_address ( Conexus::IPv4::Address  addr  )  [virtual]

References m_local_address.

bool Conexus::NSPR::Socket::set_non_blocking ( bool  set = true  ) 

void Conexus::NSPR::Socket::set_option ( PRSocketOptionData &  option  )  [virtual]

void Conexus::NSPR::Socket::set_remote_address ( Conexus::IPv4::Address  addr  )  [virtual]

void Conexus::NSPR::Socket::set_state_bound (  )  [protected, virtual]

void Conexus::NSPR::Socket::set_state_closed (  )  [protected, virtual]

void Conexus::NSPR::Socket::set_state_connected (  )  [protected, virtual]

void Conexus::NSPR::Socket::set_state_listening (  )  [protected, virtual]

sigc::signal< void > Conexus::NSPR::Socket::signal_bound (  ) 

References m_signal_bound.

sigc::signal< void > Conexus::NSPR::Socket::signal_connected (  ) 

References m_signal_connected.

sigc::signal< void > Conexus::NSPR::Socket::signal_listening (  ) 

References m_signal_listening.

void Conexus::NSPR::Socket::unset_remote_address (  )  [virtual]

size_t Conexus::NSPR::Socket::write_data ( const Data  data,
Timeout  timeout 
) throw ( write_exception ) [protected, virtual]

ssize_t Conexus::NSPR::Socket::writeto ( Address a,
const Data  data 
) throw (write_exception) [virtual]


Friends And Related Function Documentation

friend class Conexus::NSS::SSLSocket [friend]


Member Data Documentation

sigc::signal<void> Conexus::NSPR::Socket::m_signal_bound [protected]

Referenced by set_state_bound(), and signal_bound().

sigc::signal<void> Conexus::NSPR::Socket::m_signal_connected [protected]

sigc::signal<void> Conexus::NSPR::Socket::m_signal_listening [protected]


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

Generated on Wed Jul 8 15:51:29 2009 for conexus by doxygen 1.5.8