#include <P_Connection.h>
Inherited by Server.
Public Member Functions | |
int | open (NetVCOptions const &opt=DEFAULT_OPTIONS) |
Create and initialize the socket for this connection. | |
int | connect (sockaddr const *to, NetVCOptions const &opt=DEFAULT_OPTIONS) |
Connect the socket. | |
void | setRemote (sockaddr const *remote_addr) |
Set the internal socket address struct. | |
int | setup_mc_send (sockaddr const *mc_addr, sockaddr const *my_addr, bool non_blocking=NON_BLOCKING, unsigned char mc_ttl=1, bool mc_loopback=DISABLE_MC_LOOPBACK, Continuation *c=NULL) |
int | setup_mc_receive (sockaddr const *from, sockaddr const *my_addr, bool non_blocking=NON_BLOCKING, Connection *sendchan=NULL, Continuation *c=NULL) |
int | close () |
void | apply_options (NetVCOptions const &opt) |
virtual | ~Connection () |
Connection () | |
Data Fields | |
SOCKET | fd |
Socket for connection. | |
IpEndpoint | addr |
Associated address. | |
bool | is_bound |
Flag for already bound to a local address. | |
bool | is_connected |
Flag for already connected. | |
int | sock_type |
Static Public Attributes | |
static NetVCOptions const | DEFAULT_OPTIONS |
Default options. | |
Protected Member Functions | |
void | _cleanup () |
Definition at line 81 of file P_Connection.h.
Connection::~Connection | ( | ) | [virtual] |
Definition at line 79 of file Connection.cc.
References close().
Connection::Connection | ( | ) |
Definition at line 69 of file Connection.cc.
References addr.
void Connection::_cleanup | ( | ) | [protected] |
Definition at line 354 of file UnixConnection.cc.
References close().
void Connection::apply_options | ( | NetVCOptions const & | opt | ) |
Definition at line 360 of file UnixConnection.cc.
References Debug, fd, NetVCOptions::packet_mark, NetVCOptions::packet_tos, safe_setsockopt(), NetVCOptions::SOCK_OPT_KEEP_ALIVE, NetVCOptions::SOCK_OPT_NO_DELAY, sock_type, NetVCOptions::sockopt_flags, and SOCKOPT_ON.
Referenced by UnixNetVConnection::apply_options(), and open().
int Connection::close | ( | ) |
Definition at line 127 of file Connection.cc.
References SocketManager::close(), fd, is_bound, is_connected, NO_FD, and socketManager.
Referenced by _cleanup(), Server::accept(), NetAccept::acceptFastEvent(), NetAccept::cancel(), NetAcceptAction::cancel(), check_emergency_throttle(), close_UnixNetVConnection(), NetAccept::do_blocking_accept(), Server::listen(), Machine::Machine(), Server::setup_fd_for_listen(), setup_mc_receive(), setup_mc_send(), and ~Connection().
int Connection::connect | ( | sockaddr const * | to, | |
NetVCOptions const & | opt = DEFAULT_OPTIONS | |||
) |
Connect the socket.
The socket is connected to the remote addr and port. The opt structure is used to control blocking on the socket. All other options are set via open
. It is important to pass the same opt to this method as was passed to open
.
to | Remote address and port. | |
opt | Socket options |
Definition at line 320 of file UnixConnection.cc.
References _cleanup(), ats_ip_size(), NetVCOptions::f_blocking, NetVCOptions::f_blocking_connect, fd, ink_assert, is_bound, is_connected, NO_FD, safe_blocking(), safe_nonblocking(), and setRemote().
Referenced by UnixNetVConnection::connectUp().
int Connection::open | ( | NetVCOptions const & | opt = DEFAULT_OPTIONS |
) |
Create and initialize the socket for this connection.
A socket is created and the options specified by opt are set. The socket is not connected.
connect
.opt | Socket options. |
Definition at line 218 of file UnixConnection.cc.
References _cleanup(), NetVCOptions::addr_binding, apply_options(), IpEndpoint::assign(), ats_ip_size(), ats_is_ip(), Debug, NetVCOptions::f_blocking_connect, IpAddr::family(), fd, NetVCOptions::FOREIGN_ADDR, ink_assert, SocketManager::ink_bind(), ink_release_assert, NetVCOptions::INTF_ADDR, NetVCOptions::ip_family, NetVCOptions::ip_proto, is_bound, IpAddr::isValid(), NetVCOptions::local_ip, NetVCOptions::local_port, NO_FD, IpEndpoint::port(), ROUNDUP, IpEndpoint::sa, safe_nonblocking(), safe_setsockopt(), SocketManager::set_rcvbuf_size(), SocketManager::set_sndbuf_size(), IpEndpoint::setToAnyAddr(), sock_type, SocketManager::socket(), NetVCOptions::socket_recv_bufsize, NetVCOptions::socket_send_bufsize, socketManager, TS_IP_TRANSPARENT, and NetVCOptions::USE_UDP.
Referenced by UnixNetVConnection::connectUp().
void Connection::setRemote | ( | sockaddr const * | remote_addr | ) | [inline] |
Set the internal socket address struct.
remote_addr | Address and port. |
Definition at line 122 of file P_Connection.h.
References addr, and ats_ip_copy().
Referenced by connect(), and ICPPeerReadCont::PeerReadStateMachine().
int Connection::setup_mc_receive | ( | sockaddr const * | from, | |
sockaddr const * | my_addr, | |||
bool | non_blocking = NON_BLOCKING , |
|||
Connection * | sendchan = NULL , |
|||
Continuation * | c = NULL | |||
) |
Definition at line 109 of file UnixConnection.cc.
References addr, IpEndpoint::assign(), ats_ip4_addr_cast(), ats_ip_port_cast(), ats_ip_size(), ats_is_ip4(), close(), fd, ink_assert, SocketManager::ink_bind(), NO_FD, IpEndpoint::sa, safe_fcntl(), safe_nonblocking(), safe_setsockopt(), SocketManager::socket(), and socketManager.
int Connection::setup_mc_send | ( | sockaddr const * | mc_addr, | |
sockaddr const * | my_addr, | |||
bool | non_blocking = NON_BLOCKING , |
|||
unsigned char | mc_ttl = 1 , |
|||
bool | mc_loopback = DISABLE_MC_LOOPBACK , |
|||
Continuation * | c = NULL | |||
) |
Definition at line 49 of file UnixConnection.cc.
References addr, ats_ip4_addr_cast(), ats_ip_copy(), ats_ip_size(), close(), fd, ink_assert, SocketManager::ink_bind(), SocketManager::mc_socket(), NO_FD, safe_fcntl(), safe_nonblocking(), safe_setsockopt(), and socketManager.
Associated address.
Definition at line 84 of file P_Connection.h.
Referenced by Server::accept(), NetAccept::acceptEvent(), NetAccept::acceptFastEvent(), Connection(), NetAccept::do_blocking_accept(), Server::listen(), net_accept(), UnixNetVConnection::set_remote_addr(), setRemote(), Server::setup_fd_for_listen(), setup_mc_receive(), and setup_mc_send().
NetVCOptions const Connection::DEFAULT_OPTIONS [static] |
Default options.
Definition at line 145 of file P_Connection.h.
SOCKET Connection::fd |
Socket for connection.
Definition at line 83 of file P_Connection.h.
Referenced by Server::accept(), UnixNetProcessor::accept_internal(), NetAccept::acceptFastEvent(), apply_options(), check_emergency_throttle(), close(), connect(), UnixNetVConnection::connectUp(), NetAccept::do_blocking_accept(), UnixNetVConnection::do_io_shutdown(), NetAccept::do_listen(), UnixNetVConnection::free(), SSLNetVConnection::free(), UnixNetVConnection::get_socket(), MultiCastPeer::GetRecvFD(), ParentSiblingPeer::GetRecvFD(), MultiCastPeer::GetSendFD(), ParentSiblingPeer::GetSendFD(), CheckConnect::handle_connect(), Server::listen(), UnixNetVConnection::load_buffer_and_write(), net_accept(), open(), read_from_net(), MultiCastPeer::RecvFrom_re(), UnixNetVConnection::send_OOB(), send_throttle_message(), UnixNetVConnection::set_local_addr(), UnixNetVConnection::set_tcp_init_cwnd(), Server::setup_fd_for_listen(), setup_mc_receive(), setup_mc_send(), and EventIO::start().
bool Connection::is_bound |
Flag for already bound to a local address.
Definition at line 85 of file P_Connection.h.
Referenced by close(), connect(), UnixNetVConnection::connectUp(), and open().
Flag for already connected.
Definition at line 86 of file P_Connection.h.
Referenced by close(), connect(), and UnixNetVConnection::connectUp().
Definition at line 87 of file P_Connection.h.
Referenced by apply_options(), UnixNetVConnection::connectUp(), and open().