#include <conexus/socket.h>
Inheritance diagram for Conexus::Socket:
This class provides the following propertymm properties:
Public Types | |
typedef enum Conexus::Socket::SocketState | SocketState |
These enumerations are used in the socket class methods, and use is also encouraged in children. | |
enum | SocketState { BOUND = LASTENDPOINTSTATE<<1, CONNECTED = LASTENDPOINTSTATE<<2, LISTENING = LASTENDPOINTSTATE<<3, ACCEPTED = LASTENDPOINTSTATE<<4, LASTSOCKETSTATE = ACCEPTED } |
These enumerations are used in the socket class methods, and use is also encouraged in children. More... | |
Public 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 | open () throw (open_error) |
Creates the socket; similar to the socket() call. | |
virtual void | close (bool force=false) throw (close_error) |
Overloads the parent FileDescriptor class to ensure that the final state clears the BOUND, CONNECTED, LISTENING and ACCEPTED flags. | |
virtual void | bind () throw (bind_error) |
Binding without an address (autobinding) is a child specific action. | |
virtual void | bind (Conexus::Address &a) throw (bind_error) |
Binds the socket to the provided address. | |
virtual void | connect () throw (connect_error) |
Connecting without an address (autoconnecting) is a child specific action. | |
virtual void | connect (Address &a) throw (connect_error) |
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 | sd () throw () |
Returns the socket descriptor; alias for the parent accessor fd(). | |
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 Data | read (size_t s=0) throw (read_error) |
virtual ssize_t | write (const void *data, size_t size, IOMETHOD block=BLOCK) throw (write_error) |
virtual ssize_t | writeto (Address &a, const void *data, size_t size) throw (write_error) |
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 (unsigned long states) throw (state_error) |
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 () |
Protected Member Functions | |
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 () |
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 |
|
These enumerations are used in the socket class methods, and use is also encouraged in children.
|
|
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. |
|
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 error condition. Therefore children should modify this behavior if they wish to provide autobinding. Reimplemented in Conexus::IPv4::IP, and Conexus::IPv6::IP. |
|
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. |
|
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 error condition. Therefore children should modify this behavior if they wish to provide autoconnection. |
|
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. |
|
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. |
|
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:
|
|
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. |