#include <TCP_sock.H>
Public Types | |
enum | { wrong_state = -1, internal_trouble = -2, environment_problem = -3, unknown_host = -4, unknown_port = -5, invalid_parameter = -6, partner_went_away = -7, read_timeout = -8, end_of_file = partner_went_away } |
enum | { default_sndbuffer_size = 8192, default_rcvbuffer_size = 8192 } |
Public Member Functions | |
TCP_sock (u_short port=0) throw (failure) | |
~TCP_sock () throw (failure) | |
void | set_output_buffer_size (int bytes=default_sndbuffer_size) throw (failure) |
void | set_input_buffer_size (int bytes=default_rcvbuffer_size) throw (failure) |
void | enable_alerts () throw (failure) |
void | disable_alerts () throw (failure) |
void | alert () throw (failure) |
bool | test_alert () throw (failure) |
void | set_keepalive (bool state) throw (failure) |
void | enable_keepalive () throw (failure) |
void | disable_keepalive () throw (failure) |
bool | get_keepalive () throw (failure) |
void | enable_read_timeout (unsigned int seconds) throw (failure) |
void | disable_read_timeout () throw (failure) |
bool | get_read_timeout (unsigned int &seconds) throw () |
void | get_local_addr (sockaddr_in &addr) throw (failure) |
void | get_remote_addr (sockaddr_in &addr) throw (failure) |
bool | alive () throw (failure) |
fd_t | get_fd () throw () |
void | connect_to (const Text &hostname, const Text &port) throw (failure) |
void | connect_to (const Text &host_and_port) throw (failure) |
void | connect_to (sockaddr_in &addr) throw (failure) |
void | set_waiters (int waiters=1) throw (failure) |
TCP_sock * | wait_for_connect () throw (alerted, failure) |
void | send_data (const char *buffer, int len, bool flush=false) throw (failure) |
void | flush () throw (failure) |
int | recv_data (char *buffer, int len) throw (alerted, failure) |
Static Public Member Functions | |
static Text | this_host () throw (failure) |
static u_short | parse_port (const Text &port) throw (failure) |
static in_addr | host_to_addr (const Text &hostname) throw (failure) |
static void | name_to_sockaddr (const Text &hostname, const Text &port, sockaddr_in &s) throw (failure) |
static void | name_to_sockaddr (const Text &host_and_port, sockaddr_in &s) throw (failure) |
Private Types | |
enum | sock_state { fresh, listening, connected, dead } |
Private Member Functions | |
TCP_sock (TCP_sock &) | |
void | operator= (TCP_sock &) |
TCP_sock (const empty_sock_marker &) throw (TCP_sock::failure) | |
void | new_socket (u_short port) throw (failure) |
void | instance_init () throw () |
void | ensure_state (sock_state should_be) throw (failure) |
void | ensure_sndbuffer () throw () |
void | ensure_rcvbuffer () throw () |
void | configure_blocking () throw (failure) |
void | controlled_wait () throw (alerted, failure) |
int | fill_rcvbuffer () throw (alerted, failure) |
Static Private Member Functions | |
static void | init () throw (failure) |
static void | ensure_init () throw (failure) |
static void | set_no_delay (int fd) throw (failure) |
Private Attributes | |
Basics::mutex | m |
sock_state | state |
sockaddr_in | me |
sockaddr_in | him |
fd_t | fd |
char * | sndbuff |
int | sndbuff_len |
int | sndbuff_size |
char * | rcvbuff |
char * | rcvcurp |
char * | rcvend |
int | rcvbuff_size |
bool | non_blocking |
bool | alerts_enabled |
bool | alert_flag |
fd_t | pipe_wr |
fd_t | pipe_rd |
int | bytes_in_pipe |
bool | read_timeout_enabled |
unsigned int | read_timeout_secs |
Static Private Attributes | |
static pthread_once_t | init_block = PTHREAD_ONCE_INIT |
static Text | my_hostname |
static sockaddr_in | defaultsock |
static in_addr | self_addr |
static int | tcp_protolevel |
Friends | |
void | TCP_sock_init () |
Classes | |
struct | alerted |
struct | empty_sock_marker |
struct | failure |
|
Definition at line 44 of file TCP_sock.H. |
|
Definition at line 83 of file TCP_sock.H. |
|
Definition at line 274 of file TCP_sock.H. |
|
Definition at line 371 of file TCP_sock.C. References ensure_init(). |
|
Definition at line 475 of file TCP_sock.C. References alerts_enabled, internal_trouble, rcvbuff, sndbuff, and SYSERROR. |
|
|
|
Definition at line 378 of file TCP_sock.C. References ensure_init(), and SYSERROR. |
|
Definition at line 565 of file TCP_sock.C. References alert_flag, bytes_in_pipe, internal_trouble, SYSERROR, and wrong_state. |
|
Definition at line 690 of file TCP_sock.C. References dead, fd, internal_trouble, state, and SYSERROR. |
|
Definition at line 150 of file TCP_sock.C. References alerts_enabled, internal_trouble, non_blocking, read_timeout_enabled, and SYSERROR. Referenced by disable_alerts(), disable_read_timeout(), and enable_alerts(). |
|
Definition at line 1126 of file TCP_sock.C. References connected, dead, fresh, inet_ntoa_r(), internal_trouble, invalid_parameter, unknown_host, and unknown_port. |
|
Definition at line 1116 of file TCP_sock.C. References dead, and name_to_sockaddr(). |
|
Definition at line 1106 of file TCP_sock.C. References dead, and name_to_sockaddr(). |
|
Definition at line 163 of file TCP_sock.C. References alert_flag, alerts_enabled, bytes_in_pipe, dead, fd, internal_trouble, pipe_rd, read_timeout, read_timeout_enabled, read_timeout_secs, state, and SYSERROR. Referenced by fill_rcvbuffer(), and wait_for_connect(). |
|
Definition at line 549 of file TCP_sock.C. References alerts_enabled, configure_blocking(), and internal_trouble. |
|
Definition at line 118 of file TCP_sock.H. References set_keepalive(). |
|
Definition at line 645 of file TCP_sock.C. References configure_blocking(), and read_timeout_enabled. |
|
Definition at line 527 of file TCP_sock.C. References alert_flag, alerts_enabled, bytes_in_pipe, configure_blocking(), environment_problem, internal_trouble, pipe_rd, pipe_wr, and SYSERROR. Referenced by Tool_Relay::body(). |
|
Definition at line 116 of file TCP_sock.H. References set_keepalive(). Referenced by SRPC_listener::create(). |
|
Definition at line 634 of file TCP_sock.C. |
|
Definition at line 108 of file TCP_sock.C. References init_block, internal_trouble, and TCP_sock_init. Referenced by name_to_sockaddr(), TCP_sock(), and this_host(). |
|
Definition at line 143 of file TCP_sock.C. References NEW_PTRFREE_ARRAY, rcvbuff, rcvcurp, and rcvend. |
|
Definition at line 136 of file TCP_sock.C. References NEW_PTRFREE_ARRAY, sndbuff, and sndbuff_len. |
|
Definition at line 124 of file TCP_sock.C. References dead, and wrong_state. Referenced by wait_for_connect(). |
|
Definition at line 1355 of file TCP_sock.C. References controlled_wait(), dead, default_rcvbuffer_size, fd, internal_trouble, partner_went_away, rcvbuff, state, and SYSERROR. |
|
Definition at line 245 of file TCP_sock.H. References send_data(). |
|
Definition at line 208 of file TCP_sock.H. References fd. |
|
Definition at line 615 of file TCP_sock.C. References internal_trouble, and SYSERROR. |
|
Definition at line 665 of file TCP_sock.C. References self_addr. Referenced by Tool_Relay::get_sockaddr(), and SRPC::local_socket(). |
|
Definition at line 129 of file TCP_sock.H. References read_timeout_enabled, and read_timeout_secs. |
|
Definition at line 679 of file TCP_sock.C. References connected, and dead. Referenced by SRPC::remote_socket(). |
|
Definition at line 841 of file TCP_sock.C. References SYSERROR, SYSOK, and unknown_host. Referenced by init(), MastershipInit1(), name_to_sockaddr(), and UniqueIdInit::UniqueIdInit(). |
|
Definition at line 314 of file TCP_sock.C. References Text::cchars(), defaultsock, VestaConfig::get(), host_to_addr(), internal_trouble, self_addr, SYSERROR, and tcp_protolevel. Referenced by TCP_sock_init(). |
|
Definition at line 402 of file TCP_sock.C. References alerts_enabled, default_rcvbuffer_size, default_sndbuffer_size, fresh, non_blocking, rcvbuff, rcvbuff_size, rcvcurp, rcvend, read_timeout_enabled, sndbuff, sndbuff_len, sndbuff_size, and state. |
|
Definition at line 1092 of file TCP_sock.C. References invalid_parameter. |
|
Definition at line 1068 of file TCP_sock.C. References ensure_init(), host_to_addr(), and parse_port(). Referenced by connect_to(), and RunTool::send_vdir(). |
|
Definition at line 426 of file TCP_sock.C. References defaultsock, environment_problem, inet_ntoa_r(), internal_trouble, invalid_parameter, set_no_delay(), SYSERROR, and tcp_protolevel. |
|
|
|
Definition at line 739 of file TCP_sock.C. References SYSOK, TCP_NAME, and unknown_port. Referenced by name_to_sockaddr(). |
|
Definition at line 1460 of file TCP_sock.C. References connected, and min(). Referenced by Tool_Relay::body(). |
|
Definition at line 1258 of file TCP_sock.C. References connected, dead, environment_problem, FdCache::flush(), internal_trouble, min(), and SYSERROR. Referenced by flush(). |
|
Definition at line 510 of file TCP_sock.C. References invalid_parameter, and wrong_state. |
|
Definition at line 599 of file TCP_sock.C. References internal_trouble, and SYSERROR. Referenced by disable_keepalive(), and enable_keepalive(). |
|
Definition at line 390 of file TCP_sock.C. References internal_trouble, SYSERROR, and tcp_protolevel. Referenced by new_socket(), and wait_for_connect(). |
|
Definition at line 493 of file TCP_sock.C. References invalid_parameter, and wrong_state. |
|
Definition at line 1196 of file TCP_sock.C. References fresh, internal_trouble, listening, and SYSERROR. Referenced by SRPC_listener::create(), and wait_for_connect(). |
|
Definition at line 584 of file TCP_sock.C. References alert_flag, and wrong_state. Referenced by Tool_Relay::body(). |
|
Definition at line 659 of file TCP_sock.C. References ensure_init(). Referenced by RunToolHostInit(), and SRPC::this_host(). |
|
Definition at line 1205 of file TCP_sock.C. References connected, controlled_wait(), dead, ensure_state(), environment_problem, fd, fresh, him, inet_ntoa_r(), internal_trouble, listening, me, NEW_CONSTR, set_no_delay(), set_waiters(), state, and SYSERROR. Referenced by Tool_Relay::body(), and SRPC_impl::read_item_code(). |
|
Definition at line 101 of file TCP_sock.C. Referenced by ensure_init(). |
|
Definition at line 291 of file TCP_sock.H. Referenced by alert(), controlled_wait(), enable_alerts(), and test_alert(). |
|
Definition at line 290 of file TCP_sock.H. Referenced by configure_blocking(), controlled_wait(), disable_alerts(), enable_alerts(), instance_init(), and ~TCP_sock(). |
|
Definition at line 294 of file TCP_sock.H. Referenced by alert(), controlled_wait(), and enable_alerts(). |
|
Definition at line 73 of file TCP_sock.C. Referenced by init(), and new_socket(). |
|
Definition at line 279 of file TCP_sock.H. Referenced by alive(), controlled_wait(), fill_rcvbuffer(), get_fd(), and wait_for_connect(). |
|
Definition at line 278 of file TCP_sock.H. Referenced by wait_for_connect(). |
|
Definition at line 69 of file TCP_sock.C. Referenced by ensure_init(). |
|
Definition at line 272 of file TCP_sock.H. |
|
Definition at line 277 of file TCP_sock.H. Referenced by wait_for_connect(). |
|
Definition at line 72 of file TCP_sock.C. |
|
Definition at line 288 of file TCP_sock.H. Referenced by configure_blocking(), and instance_init(). |
|
Definition at line 293 of file TCP_sock.H. Referenced by controlled_wait(), and enable_alerts(). |
|
Definition at line 292 of file TCP_sock.H. Referenced by enable_alerts(). |
|
Definition at line 283 of file TCP_sock.H. Referenced by ensure_rcvbuffer(), fill_rcvbuffer(), instance_init(), and ~TCP_sock(). |
|
Definition at line 286 of file TCP_sock.H. Referenced by instance_init(). |
|
Definition at line 284 of file TCP_sock.H. Referenced by ensure_rcvbuffer(), and instance_init(). |
|
Definition at line 285 of file TCP_sock.H. Referenced by ensure_rcvbuffer(), and instance_init(). |
|
Definition at line 297 of file TCP_sock.H. Referenced by configure_blocking(), controlled_wait(), disable_read_timeout(), get_read_timeout(), and instance_init(). |
|
Definition at line 298 of file TCP_sock.H. Referenced by controlled_wait(), and get_read_timeout(). |
|
Definition at line 74 of file TCP_sock.C. Referenced by get_local_addr(), and init(). |
|
Definition at line 280 of file TCP_sock.H. Referenced by ensure_sndbuffer(), instance_init(), and ~TCP_sock(). |
|
Definition at line 281 of file TCP_sock.H. Referenced by ensure_sndbuffer(), and instance_init(). |
|
Definition at line 282 of file TCP_sock.H. Referenced by instance_init(). |
|
Definition at line 275 of file TCP_sock.H. Referenced by alive(), controlled_wait(), fill_rcvbuffer(), instance_init(), and wait_for_connect(). |
|
Definition at line 75 of file TCP_sock.C. Referenced by init(), new_socket(), and set_no_delay(). |