#include <conexus/socket.h>
Inheritance diagram for Conexus::Socket:
This class provides the following propertymm properties:
Public Types | |
typedef ConexusPointer< Socket > | pointer |
typedef ConexusPointer< Socket > | pointer |
typedef ConexusPointer< Socket > | pointer |
Public Member Functions | |
virtual void | open () throw ( open_exception ) |
Creates the socket; similar to the socket() call. | |
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 specified 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. | |
int | domain () throw () |
Returns the communication domain which specifies the protocol family of the socket. | |
void | set_domain (int) throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated. | |
int | type () throw () |
Returns the socket type, which defines the communication mechanism of the socket. | |
void | set_type (int) throw () |
Sets the socket type, which defines the communication mechanism of the socket. | |
int | protocol () throw () |
Returns the specific protocol within the socket's protocol family. | |
void | set_protocol (int) throw () |
Sets the specific protocol within the socket's protocol family, but is normally 0. | |
virtual ssize_t | writeto (Address &a, const Data data) throw ( write_exception ) |
virtual void | set_option (int option, bool b) |
template<typename T> | |
void | set_option (int level, int optname, T &value) |
template<typename T> | |
void | option (int level, int optname, T &value) |
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 () |
Socket (int domain=-1, int type=-1, int protocol=0) throw () | |
This default constructor is primarily for children to specify a domain, type and socket protocol. | |
virtual void | open () throw (open_exception) |
Creates the socket; similar to the socket() call. | |
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 (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 (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. | |
int | domain () throw () |
Returns the communication domain which specifies the protocol family of the socket. | |
void | set_domain (int) throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated. | |
int | type () throw () |
Returns the socket type, which defines the communication mechanism of the socket. | |
void | set_type (int) throw () |
Sets the socket type, which defines the communication mechanism of the socket. | |
int | protocol () throw () |
Returns the specific protocol within the socket's protocol family. | |
void | set_protocol (int) throw () |
Sets the specific protocol within the socket's protocol family, but is normally 0. | |
virtual ssize_t | writeto (Address &a, Data::const_pointer data) throw (write_exception) |
virtual void | set_option (int option, bool b) |
template<typename T> | |
void | set_option (int level, int optname, T &value) |
template<typename T> | |
void | option (int level, int optname, T &value) |
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 () |
virtual const std::string & | object_type () |
Socket (int domain=-1, int type=-1, int protocol=0) throw () | |
This default constructor is primarily for children to specify a domain, type and socket protocol. | |
virtual void | open () throw (open_exception) |
Creates the socket; similar to the socket() call. | |
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 (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 (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. | |
int | domain () throw () |
Returns the communication domain which specifies the protocol family of the socket. | |
void | set_domain (int) throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated. | |
int | type () throw () |
Returns the socket type, which defines the communication mechanism of the socket. | |
void | set_type (int) throw () |
Sets the socket type, which defines the communication mechanism of the socket. | |
int | protocol () throw () |
Returns the specific protocol within the socket's protocol family. | |
void | set_protocol (int) throw () |
Sets the specific protocol within the socket's protocol family, but is normally 0. | |
virtual ssize_t | writeto (Address &a, Data::const_pointer data) throw (write_exception) |
virtual void | set_option (int option, bool b) |
template<typename T> | |
void | set_option (int level, int optname, T &value) |
template<typename T> | |
void | option (int level, int optname, T &value) |
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 () |
virtual const std::string & | object_type () |
Static Public Member Functions | |
static pointer | create (int domain=-1, int type=-1, int protocol=0) throw () |
Protected Member Functions | |
Socket (int domain=-1, int type=-1, int protocol=0) throw () | |
This default constructor is primarily for children to specify a domain, type and socket protocol. | |
virtual void | read_thread_main () |
virtual void | set_state_closed () |
virtual void | set_state_bound () |
virtual void | set_state_connected () |
virtual void | set_state_listening () |
virtual ssize_t | write_data (long int timeout, const Data data) throw ( write_exception ) |
virtual Data | read_data (long int timeout, size_t s=0) throw ( read_exception ) |
virtual void | read_thread_main () |
virtual void | set_state_closed () |
virtual void | set_state_bound () |
virtual void | set_state_connected () |
virtual void | set_state_listening () |
virtual ssize_t | write_data (long int timeout, Data::const_pointer data) throw (write_exception) |
virtual Data::pointer | read_data (long int timeout, size_t s=0) throw (read_exception) |
virtual void | read_thread_main () |
virtual void | set_state_closed () |
virtual void | set_state_bound () |
virtual void | set_state_connected () |
virtual void | set_state_listening () |
virtual ssize_t | write_data (long int timeout, Data::const_pointer data) throw (write_exception) |
virtual Data::pointer | read_data (long int timeout, size_t s=0) throw (read_exception) |
Protected Attributes | |
int | m_domain |
int | m_type |
int | m_protocol |
sigc::signal< void > | m_signal_bound |
sigc::signal< void > | m_signal_connected |
sigc::signal< void > | m_signal_listening |
sigc::signal< void > | m_signal_bound |
sigc::signal< void > | m_signal_connected |
sigc::signal< void > | m_signal_listening |
sigc::signal< void > | m_signal_bound |
sigc::signal< void > | m_signal_connected |
sigc::signal< void > | m_signal_listening |
void Conexus::Socket::open | ( | ) | throw ( open_exception ) [virtual] |
Creates the socket; similar to the socket() call.
Ideally, the socket will be in the CLOSED state before this call.
If the socket is in the OPENED state (not BOUND, CONNECTED, LISTENING, ACCEPTED...) this method will return without performing any action.
If the socket is in any state other than CLOSED or OPENED the socket will be closed and reopened.
Implements Conexus::Endpoint.
void Conexus::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::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, and Conexus::IPv6::UDPPoset.
void Conexus::Socket::bind | ( | const Conexus::Address & | a | ) | throw ( bind_exception ) [virtual] |
Binds the socket to the specified 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.
Reimplemented in Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
void Conexus::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::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
void Conexus::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.
void Conexus::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.
void Conexus::Socket::set_domain | ( | int | ) | throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated.
Linux currently defines the following protocol families:
Name | Purpose | Man page |
PF_UNIX, PF_LOCAL | Local communication | unix(7) |
PF_INET | IPv4 Internet protocols | ip(7) |
PF_INET6 | IPv6 Internet protocols | |
PF_IPX | IPX - Novell protocols | |
PF_NETLINK | Kernel user interface device | netlink(7) |
PF_X25 | ITU-T X.25 / ISO-8208 protocol | x25(7) |
PF_AX25 | Amateur radio AX.25 protocol | |
PF_ATMPVC | Access to raw ATM PVCs | |
PF_APPLETALK | Appletalk | ddp(7) |
PF_PACKET | Low level packet interface | packet(7) |
void Conexus::Socket::set_type | ( | int | ) | throw () |
Sets the socket type, which defines the communication mechanism of the socket.
Linux currently defines the following communication types:
Some socket types may not be implemented by all protocol families; for example, SOCK_SEQPACKET is not implemented for AF_INET.
virtual void Conexus::Socket::open | ( | ) | throw (open_exception) [virtual] |
Creates the socket; similar to the socket() call.
Ideally, the socket will be in the CLOSED state before this call.
If the socket is in the OPENED state (not BOUND, CONNECTED, LISTENING, ACCEPTED...) this method will return without performing any action.
If the socket is in any state other than CLOSED or OPENED the socket will be closed and reopened.
Implements Conexus::Endpoint.
virtual void Conexus::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::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, and Conexus::IPv6::UDPPoset.
virtual void Conexus::Socket::bind | ( | 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.
Reimplemented in Conexus::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
virtual void Conexus::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::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
virtual void Conexus::Socket::connect | ( | 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.
virtual void Conexus::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.
void Conexus::Socket::set_domain | ( | int | ) | throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated.
Linux currently defines the following protocol families:
Name | Purpose | Man page |
PF_UNIX, PF_LOCAL | Local communication | unix(7) |
PF_INET | IPv4 Internet protocols | ip(7) |
PF_INET6 | IPv6 Internet protocols | |
PF_IPX | IPX - Novell protocols | |
PF_NETLINK | Kernel user interface device | netlink(7) |
PF_X25 | ITU-T X.25 / ISO-8208 protocol | x25(7) |
PF_AX25 | Amateur radio AX.25 protocol | |
PF_ATMPVC | Access to raw ATM PVCs | |
PF_APPLETALK | Appletalk | ddp(7) |
PF_PACKET | Low level packet interface | packet(7) |
void Conexus::Socket::set_type | ( | int | ) | throw () |
Sets the socket type, which defines the communication mechanism of the socket.
Linux currently defines the following communication types:
Some socket types may not be implemented by all protocol families; for example, SOCK_SEQPACKET is not implemented for AF_INET.
virtual void Conexus::Socket::open | ( | ) | throw (open_exception) [virtual] |
Creates the socket; similar to the socket() call.
Ideally, the socket will be in the CLOSED state before this call.
If the socket is in the OPENED state (not BOUND, CONNECTED, LISTENING, ACCEPTED...) this method will return without performing any action.
If the socket is in any state other than CLOSED or OPENED the socket will be closed and reopened.
Implements Conexus::Endpoint.
virtual void Conexus::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::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, Conexus::IPv6::UDPPoset, Conexus::IPv4::IP, Conexus::IPv4::UDPPoset, Conexus::IPv6::IP, and Conexus::IPv6::UDPPoset.
virtual void Conexus::Socket::bind | ( | 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.
Reimplemented in Conexus::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
virtual void Conexus::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::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, Conexus::IPv6::UDPPoset, Conexus::IPv4::UDPPoset, and Conexus::IPv6::UDPPoset.
virtual void Conexus::Socket::connect | ( | 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.
virtual void Conexus::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.
void Conexus::Socket::set_domain | ( | int | ) | throw () |
Sets the communication domain which specifies the protocol family of the socket; this will only set the domain internally, but will not have an actual effect until the socket is created, or if the socket is already created it will not have an effect until the socket is closed and recreated.
Linux currently defines the following protocol families:
Name | Purpose | Man page |
PF_UNIX, PF_LOCAL | Local communication | unix(7) |
PF_INET | IPv4 Internet protocols | ip(7) |
PF_INET6 | IPv6 Internet protocols | |
PF_IPX | IPX - Novell protocols | |
PF_NETLINK | Kernel user interface device | netlink(7) |
PF_X25 | ITU-T X.25 / ISO-8208 protocol | x25(7) |
PF_AX25 | Amateur radio AX.25 protocol | |
PF_ATMPVC | Access to raw ATM PVCs | |
PF_APPLETALK | Appletalk | ddp(7) |
PF_PACKET | Low level packet interface | packet(7) |
void Conexus::Socket::set_type | ( | int | ) | throw () |
Sets the socket type, which defines the communication mechanism of the socket.
Linux currently defines the following communication types:
Some socket types may not be implemented by all protocol families; for example, SOCK_SEQPACKET is not implemented for AF_INET.