feisty meow concerns codebase
2.140
|
Abstraction for a higher-level BSD socket that is platform independent. More...
#include <spocket.h>
Public Types | |
enum | sock_types { CONNECTED , BROADCAST , UNICAST , BOGUS_SOCK } |
enum | outcomes { OKAY = basis::common::OKAY , TIMED_OUT = basis::common::TIMED_OUT , ACCESS_DENIED = basis::common::ACCESS_DENIED , BAD_INPUT = basis::common::BAD_INPUT , NONE_READY = basis::common::NONE_READY , PARTIAL = basis::common::PARTIAL , NO_CONNECTION = sockets::communication_commons::NO_CONNECTION , NO_ANSWER = sockets::communication_commons::NO_ANSWER , DEFINE_OUTCOME } |
Static Public Member Functions | |
static const char * | outcome_name (const basis::outcome &to_name) |
Abstraction for a higher-level BSD socket that is platform independent.
The class works on Unix and Win32 style operating systems. This class is named in honor of the venerable Vulcan Spock, which also avoid naming conflicts with the OS's socket() function.
sockets::spocket::spocket | ( | const internet_address & | where, |
sock_types | type = CONNECTED |
||
) |
Definition at line 99 of file spocket.cpp.
sockets::spocket::~spocket | ( | ) |
Definition at line 128 of file spocket.cpp.
References FUNCDEF, LOG, and basis::WHACK().
Definition at line 460 of file spocket.cpp.
References CHECK_BOGUS, sockets::internet_address::convert(), FUNCDEF, INVALID_SOCKET, LOG, NULL_POINTER, sockets::PENDING_CONNECTIONS_ALLOWED, SOCK_EWOULDBLOCK, and basis::astring::text_form().
Referenced by spocket_tester::accept().
outcome sockets::spocket::await_readable | ( | int | timeout | ) |
Definition at line 238 of file spocket.cpp.
References CHECK_BOGUS, ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, RECOGNIZE_DISCO, sockets::SI_DISCONNECTED, and sockets::SI_READABLE.
outcome sockets::spocket::await_writable | ( | int | timeout | ) |
Definition at line 256 of file spocket.cpp.
References CHECK_BOGUS, ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, RECOGNIZE_DISCO, sockets::SI_DISCONNECTED, and sockets::SI_WRITABLE.
Referenced by spocket_tester::do_a_send(), and cromp::cromp_common::push_outgoing().
void sockets::spocket::bind_client | ( | const internet_address & | source | ) |
when a client calls connect, this forces it to bind to "source".
this has no effect on servers. it is also disabled again when the client is disconnected, so it should always be done before every time connect() is called.
Definition at line 174 of file spocket.cpp.
|
inline |
Definition at line 152 of file spocket.h.
Referenced by spocket_tester::perform_test().
outcome sockets::spocket::connect | ( | int | communication_wait = 20 * basis::SECOND_ms | ) |
Definition at line 274 of file spocket.cpp.
References CHECK_BOGUS, FUNCDEF, GRAB_LOCK, INVALID_SOCKET, basis::array< contents >::length(), LOG, basis::negative(), SOCK_ECONNREFUSED, SOCK_EINPROGRESS, SOCK_EISCONN, SOCK_EWOULDBLOCK, SOCKET_ERROR, basis::array< contents >::stuff(), and basis::astring::text_form().
Referenced by broadcast_spocket_tester::connect(), and spocket_tester::connect().
bool sockets::spocket::connected | ( | ) |
Definition at line 209 of file spocket.cpp.
References ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, LOG, RECOGNIZE_DISCO, sockets::SI_DISCONNECTED, and sockets::SI_ERRONEOUS.
Referenced by cromp::cromp_client::connected(), and cromp::cromp_common::push_outgoing().
sockets::spocket::DEFINE_CLASS_NAME | ( | "spocket" | ) |
outcome sockets::spocket::disconnect | ( | ) |
Definition at line 188 of file spocket.cpp.
References FUNCDEF, LOG, and RECOGNIZE_DISCO.
Referenced by cromp::cromp_common::close_common().
bool sockets::spocket::healthy | ( | ) |
|
inline |
returns true when this object is bogus.
a spocket constructed as BOGUS_SOCK does not open a network connection to anywhere, and it also never sends or receives any data. it allows code based on spockets to be disabled when appropriate, so that the spocket is still constructed and all methods can be invoked, but it does nothing.
Definition at line 211 of file spocket.h.
References BOGUS_SOCK.
|
inline |
Definition at line 106 of file spocket.h.
References is_server().
|
inline |
Definition at line 105 of file spocket.h.
Referenced by is_root_server().
|
inline |
|
inline |
Definition at line 108 of file spocket.h.
Referenced by cromp::cromp_common::send_buffer().
|
static |
Definition at line 180 of file spocket.cpp.
References basis::outcome::value().
outcome sockets::spocket::receive | ( | basis::abyte * | buffer, |
int & | size | ||
) |
Definition at line 664 of file spocket.cpp.
References CHECK_BOGUS, ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, LOG, RECOGNIZE_DISCO, sockets::SI_DISCONNECTED, and SOCK_EWOULDBLOCK.
Referenced by spocket_tester::do_a_receive().
outcome sockets::spocket::receive | ( | basis::byte_array & | buffer, |
int & | size | ||
) |
Definition at line 650 of file spocket.cpp.
References basis::array< contents >::access(), CHECK_BOGUS, FUNCDEF, basis::array< contents >::last(), basis::array< contents >::reset(), and basis::array< contents >::zap().
outcome sockets::spocket::receive_from | ( | basis::abyte * | buffer, |
int & | size, | ||
internet_address & | where_from | ||
) |
Definition at line 713 of file spocket.cpp.
References CHECK_BOGUS, sockets::internet_address::convert(), ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, LOG, SOCK_ECONNRESET, and SOCK_EWOULDBLOCK.
Referenced by broadcast_spocket_tester::do_a_receive().
outcome sockets::spocket::receive_from | ( | basis::byte_array & | buffer, |
int & | size, | ||
internet_address & | where_from | ||
) |
Definition at line 697 of file spocket.cpp.
References basis::array< contents >::access(), CHECK_BOGUS, FUNCDEF, basis::array< contents >::last(), basis::array< contents >::reset(), and basis::array< contents >::zap().
const internet_address & sockets::spocket::remote | ( | ) | const |
Definition at line 148 of file spocket.cpp.
outcome sockets::spocket::send | ( | const basis::abyte * | buffer, |
int | size, | ||
int & | len_sent | ||
) |
Definition at line 573 of file spocket.cpp.
References CHECK_BOGUS, ENSURE_HEALTH, FUNCDEF, GRAB_LOCK, LOG, SOCK_EWOULDBLOCK, and SOCKET_ERROR.
Referenced by spocket_tester::do_a_send(), and cromp::cromp_common::send_buffer().
outcome sockets::spocket::send | ( | const basis::byte_array & | to_send, |
int & | len_sent | ||
) |
Definition at line 568 of file spocket.cpp.
References basis::array< contents >::length(), and basis::array< contents >::observe().
outcome sockets::spocket::send_to | ( | const internet_address & | where_to, |
const basis::abyte * | buffer, | ||
int | size, | ||
int & | len_sent | ||
) |
Definition at line 628 of file spocket.cpp.
References CHECK_BOGUS, FUNCDEF, LOG, and SOCK_EWOULDBLOCK.
Referenced by broadcast_spocket_tester::do_a_send().
outcome sockets::spocket::send_to | ( | const internet_address & | where_to, |
const basis::byte_array & | to_send, | ||
int & | len_sent | ||
) |
Definition at line 622 of file spocket.cpp.
References basis::array< contents >::length(), and basis::array< contents >::observe().
tcpip_stack & sockets::spocket::stack | ( | ) | const |
Definition at line 150 of file spocket.cpp.
astring sockets::spocket::text_form | ( | ) |
Definition at line 154 of file spocket.cpp.
References FUNCDEF, and basis::astring::text_form().
const internet_address & sockets::spocket::where | ( | ) | const |
Definition at line 147 of file spocket.cpp.
Referenced by cromp::cromp_common::other_side().