#include <socket.h>
Public Types | |
typedef ConexusPointer< Socket > | pointer |
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::Address & | local_address () |
virtual Conexus::IPv4::Address & | remote_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 |
This class provides the following propertymm properties:
typedef ConexusPointer<Socket> Conexus::NSPR::Socket::pointer |
Reimplemented from Conexus::NSPR::FileDescriptor.
Reimplemented in Conexus::NSPR::TCP, Conexus::NSPR::UDP, and Conexus::NSS::SSLSocket.
Conexus::NSPR::Socket::Socket | ( | ) | throw () [protected] |
Conexus::NSPR::Socket::~Socket | ( | ) | throw () [virtual] |
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] |
Reimplemented from Conexus::Endpoint.
References Conexus::Endpoint::change_state(), Conexus::ENDPOINT_CLOSED, Conexus::SOCKET_ACCEPTED, Conexus::SOCKET_BOUND, Conexus::SOCKET_CONNECTED, and Conexus::SOCKET_LISTENING.
Referenced by listen(), Conexus::NSPR::UDP::open(), and Conexus::NSPR::TCP::open().
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 | ( | ) |
References Conexus::Endpoint::m_state, and Conexus::SOCKET_ACCEPTED.
Referenced by Conexus::NSPR::TCP::on_local_address_changed(), and Conexus::NSPR::TCP::on_remote_address_changed().
bool Conexus::NSPR::Socket::is_bound | ( | ) |
References Conexus::Endpoint::m_state, and Conexus::SOCKET_BOUND.
Referenced by listen(), Conexus::NSPR::TCP::on_local_address_changed(), and set_state_bound().
bool Conexus::NSPR::Socket::is_connected | ( | ) |
References Conexus::Endpoint::m_state, and Conexus::SOCKET_CONNECTED.
Referenced by Conexus::NSPR::TCP::on_remote_address_changed(), set_state_connected(), and Conexus::NSPR::TCP::shutdown().
bool Conexus::NSPR::Socket::is_listening | ( | ) |
References Conexus::Endpoint::m_state, and Conexus::SOCKET_LISTENING.
Referenced by set_state_listening().
bool Conexus::NSPR::Socket::is_non_blocking | ( | ) |
References Conexus::NSPR::FileDescriptor::m_fd, and m_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] |
void Conexus::NSPR::Socket::on_local_address_changed_proxy | ( | ) | [protected] |
void Conexus::NSPR::Socket::on_remote_address_changed | ( | ) | [protected, virtual] |
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 |
) |
References Conexus::Endpoint::is_open(), Conexus::NSPR::FileDescriptor::m_fd, and m_non_blocking.
Referenced by Conexus::NSPR::UDP::open(), and Conexus::NSPR::TCP::open().
void Conexus::NSPR::Socket::set_option | ( | PRSocketOptionData & | option | ) | [virtual] |
References Conexus::NSPR::FileDescriptor::m_fd.
void Conexus::NSPR::Socket::set_remote_address | ( | Conexus::IPv4::Address | addr | ) | [virtual] |
References m_remote_address, and m_remote_address_set.
void Conexus::NSPR::Socket::set_state_bound | ( | ) | [protected, virtual] |
References is_bound(), m_signal_bound, Conexus::Endpoint::m_state, and Conexus::SOCKET_BOUND.
void Conexus::NSPR::Socket::set_state_closed | ( | ) | [protected, virtual] |
Reimplemented from Conexus::Endpoint.
References Conexus::Endpoint::is_closed(), Conexus::Endpoint::m_state, Conexus::SOCKET_ACCEPTED, Conexus::SOCKET_BOUND, Conexus::SOCKET_CONNECTED, and Conexus::SOCKET_LISTENING.
void Conexus::NSPR::Socket::set_state_connected | ( | ) | [protected, virtual] |
References is_connected(), m_signal_connected, Conexus::Endpoint::m_state, and Conexus::SOCKET_CONNECTED.
void Conexus::NSPR::Socket::set_state_listening | ( | ) | [protected, virtual] |
References is_listening(), m_signal_listening, Conexus::Endpoint::m_state, and Conexus::SOCKET_LISTENING.
Referenced by listen().
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] |
References m_remote_address, and m_remote_address_set.
size_t Conexus::NSPR::Socket::write_data | ( | const Data | data, | |
Timeout | timeout | |||
) | throw ( write_exception ) [protected, virtual] |
Reimplemented from Conexus::NSPR::FileDescriptor.
Reimplemented in Conexus::NSPR::TCP, and Conexus::NSPR::UDP.
Referenced by Conexus::NSPR::UDP::write_data(), and Conexus::NSPR::TCP::write_data().
ssize_t Conexus::NSPR::Socket::writeto | ( | Address & | a, | |
const Data | data | |||
) | throw (write_exception) [virtual] |
References Conexus::NSPR::addr_to_nspr(), and Conexus::ENDPOINT_OPENED.
Referenced by Conexus::NSPR::UDP::write_data().
friend class Conexus::NSS::SSLSocket [friend] |
Referenced by Conexus::NSPR::UDP::bind(), bind(), local_address(), set_local_address(), Socket(), and Conexus::NSPR::UDP::UDP().
bool Conexus::NSPR::Socket::m_non_blocking [protected] |
Referenced by is_non_blocking(), Conexus::NSPR::UDP::open(), Conexus::NSPR::TCP::open(), and set_non_blocking().
bool Conexus::NSPR::Socket::m_remote_address_set [protected] |
Referenced by on_remote_address_changed_proxy(), set_remote_address(), and unset_remote_address().
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] |
Referenced by set_state_connected(), and signal_connected().
sigc::signal<void> Conexus::NSPR::Socket::m_signal_listening [protected] |
Referenced by set_state_listening(), and signal_listening().