S3FC project page | S3FC home page |
#include <s3_socket_tcp.h>
Inheritance diagram for s3_socket_tcp:
Public Methods | |
s3_socket_tcp (int newsock=INVALID_SOCKET, bool new_set_reuseaddr=true) throw (s3_generic_exception) | |
Construct a new socket. More... | |
s3_socket_tcp (const s3_socket_tcp &template_sock) throw (s3_generic_exception) | |
Copy construct a new socket. More... | |
virtual | ~s3_socket_tcp () |
bool | bind (in_addr_t addr, in_port_t port) |
Bind the socket to local addr:port. More... | |
bool | listen (int backlog) |
Put the socket in listen mode. More... | |
bool | accept (s3_socket_tcp &newsock, sockaddr_in *clientname=0) |
Accept a connection on the socket. More... | |
bool | connect (const std::string &IP_address, in_port_t port) |
Connect the socket to addr:port. More... | |
bool | close (bool reinit=true) throw (s3_generic_exception) |
Close the socket. More... | |
std::string | get_error () const |
Returns a string describing the most recent error. More... | |
int | get_errno () const |
Returns the error number of the most recent error. More... | |
int | get_h_errno () const |
Returns the error number of the most recent host error. More... | |
bool | is_closed () const |
Returns whether the socket is closed. More... | |
bool | is_valid () const |
Returns whether the socket is valid. More... | |
virtual bool | read (void *data, int size, s3_semaphore *term=0) |
Reads data from socket in non-blocking mode, and is guaranteed to wait until all the data (as indicated by size) has been read from the socket. More... | |
virtual bool | write (void *data, int size, int max_packet=-1, s3_semaphore *term=0) |
Writes data to a connect()ed socket, optionally limiting packet size to some reasonable value. More... | |
int | select_rd (int timeout=1) |
Wait for socket to become readable. More... | |
int | select_wr (int timeout=1) |
Wait for socket to become writeable or time out. More... | |
Protected Methods | |
void | set_errnos (int new_errno=0, int new_h_errno=0) |
void | change_socket (int newsock) |
Protected Attributes | |
bool | set_reuseaddr |
int | sock |
int | my_errno |
int | my_h_errno |
Private Methods | |
bool | initialize () |
Friends | |
bool | accept (s3_socket_tcp &newsock, sockaddr_in *clientname) |
allows accept to access newsock.change_socket(). More... |
|
Construct a new socket.
Definition at line 41 of file s3_socket_tcp.cc. References INVALID_SOCKET. |
|
Copy construct a new socket.
Definition at line 59 of file s3_socket_tcp.cc. |
|
Definition at line 70 of file s3_socket_tcp.cc. References close. |
|
Accept a connection on the socket.
Definition at line 145 of file s3_socket_tcp.cc. References change_socket, S3FC_DBG2_, S3FC_DBG_, set_errnos, and sock. Referenced by s3_socket_tcp_ssl::accept. |
|
Bind the socket to local addr:port.
Definition at line 113 of file s3_socket_tcp.cc. References S3FC_DBG2_, S3FC_DBG_, set_errnos, and sock. |
|
Definition at line 107 of file s3_socket_tcp.cc. Referenced by accept. |
|
Close the socket.
Reimplemented in s3_socket_tcp_ssl. Definition at line 205 of file s3_socket_tcp.cc. References INVALID_SOCKET, S3FC_DBG2_, and S3FC_DBG_. Referenced by change_socket, s3_socket_tcp_ssl::close, and ~s3_socket_tcp. |
|
Connect the socket to addr:port.
Reimplemented in s3_socket_tcp_ssl. Definition at line 168 of file s3_socket_tcp.cc. References S3FC_DBG2_, S3FC_DBG_, set_errnos, and sock. Referenced by s3_socket_tcp_ssl::connect. |
|
Returns the error number of the most recent error.
Definition at line 100 of file s3_socket_tcp.h. References my_errno. |
|
Returns a string describing the most recent error.
Reimplemented in s3_socket_tcp_ssl. Definition at line 236 of file s3_socket_tcp.cc. References my_errno, my_h_errno, S3FC_DBG2_, and S3FC_DBG_. Referenced by s3_socket_tcp_ssl::get_error. |
|
Returns the error number of the most recent host error.
Definition at line 106 of file s3_socket_tcp.h. References my_h_errno. |
|
Definition at line 75 of file s3_socket_tcp.cc. References INVALID_SOCKET, S3FC_DBG2_, set_errnos, and sock. |
|
Returns whether the socket is closed.
Definition at line 112 of file s3_socket_tcp.h. References sock. |
|
Returns whether the socket is valid.
Definition at line 118 of file s3_socket_tcp.h. References INVALID_SOCKET, and sock. |
|
Put the socket in listen mode.
Definition at line 131 of file s3_socket_tcp.cc. References S3FC_DBG2_, S3FC_DBG_, set_errnos, and sock. |
|
Reads data from socket in non-blocking mode, and is guaranteed to wait until all the data (as indicated by size) has been read from the socket. It calls s3_thread_base::test_cancel() in the loop to ensure that this call will not block the thread termination process.
Reimplemented in s3_socket_tcp_ssl. Definition at line 280 of file s3_socket_tcp.cc. References S3FC_DBG2_, select_rd, set_errnos, sock, s3_thread_base::test_cancel, and s3_semaphore::try_wait. |
|
Wait for socket to become readable. This function returns true if something is waiting to be read at the socket using select(2). It returns true if there is something in the receive buffer (i.e. a recv will return a positive number). If it times out, or if there is nothing in the buffer, it returns false.
Definition at line 468 of file s3_socket_tcp.cc. References set_errnos, and sock. Referenced by s3_socket_tcp_ssl::read, and read. |
|
Wait for socket to become writeable or time out. This function returns true if the socket is writeable using select(2). It returns true if there is enough space in the send buffer (i.e. a send(2) will return a positive number). If it times out, or if the buffer is full, it returns false.
Definition at line 499 of file s3_socket_tcp.cc. References set_errnos, and sock. Referenced by s3_socket_tcp_ssl::write, and write. |
|
Definition at line 101 of file s3_socket_tcp.cc. References my_errno, and my_h_errno. Referenced by accept, bind, connect, initialize, listen, s3_socket_tcp_ssl::read, read, select_rd, select_wr, s3_socket_tcp_ssl::set_errnos, s3_socket_tcp_ssl::write, and write. |
|
Writes data to a connect()ed socket, optionally limiting packet size to some reasonable value. It calls s3_thread_base::test_cancel() in the loop to ensure that this call will not block the thread termination process.
Reimplemented in s3_socket_tcp_ssl. Definition at line 390 of file s3_socket_tcp.cc. References S3FC_DBG_, select_wr, set_errnos, sock, s3_thread_base::test_cancel, and s3_semaphore::try_wait. |
|
allows accept to access newsock.change_socket().
|
|
Definition at line 67 of file s3_socket_tcp.h. Referenced by get_errno, get_error, and set_errnos. |
|
Definition at line 67 of file s3_socket_tcp.h. Referenced by get_error, get_h_errno, and set_errnos. |
|
Definition at line 66 of file s3_socket_tcp.h. |
|
Definition at line 67 of file s3_socket_tcp.h. Referenced by accept, bind, change_socket, connect, initialize, is_closed, is_valid, listen, read, select_rd, select_wr, s3_socket_tcp_ssl::setup_ssl, and write. |
Send comments to: s3fc@stonethree.com |
|