Utility class for socket operations. More...
#include <I_SocketManager.h>
Public Member Functions | |
SocketManager () | |
SOCKET | socket (int domain=AF_INET, int type=SOCK_STREAM, int protocol=0, bool bNonBlocking=true) |
SOCKET | mc_socket (int domain=AF_INET, int type=SOCK_DGRAM, int protocol=0, bool bNonBlocking=true) |
int | open (const char *path, int oflag=O_RDWR|O_NDELAY|O_CREAT, mode_t mode=DEFAULT_OPEN_MODE) |
int64_t | read (int fd, void *buf, int len, void *pOLP=NULL) |
int64_t | vector_io (int fd, struct iovec *vector, size_t count, int read_request, void *pOLP=0) |
int64_t | readv (int fd, struct iovec *vector, size_t count) |
int64_t | read_vector (int fd, struct iovec *vector, size_t count, void *pOLP=0) |
int64_t | pread (int fd, void *buf, int len, off_t offset, char *tag=NULL) |
int | recv (int s, void *buf, int len, int flags) |
int | recvfrom (int fd, void *buf, int size, int flags, struct sockaddr *addr, socklen_t *addrlen) |
int64_t | write (int fd, void *buf, int len, void *pOLP=NULL) |
int64_t | writev (int fd, struct iovec *vector, size_t count) |
int64_t | write_vector (int fd, struct iovec *vector, size_t count, void *pOLP=0) |
int64_t | pwrite (int fd, void *buf, int len, off_t offset, char *tag=NULL) |
int | send (int fd, void *buf, int len, int flags) |
int | sendto (int fd, void *buf, int len, int flags, struct sockaddr const *to, int tolen) |
int | sendmsg (int fd, struct msghdr *m, int flags, void *pOLP=0) |
int64_t | lseek (int fd, off_t offset, int whence) |
int | fstat (int fd, struct stat *) |
int | unlink (char *buf) |
int | fsync (int fildes) |
int | ftruncate (int fildes, off_t length) |
int | lockf (int fildes, int function, off_t size) |
int | poll (struct pollfd *fds, unsigned long nfds, int timeout) |
int | shutdown (int s, int how) |
int | dup (int s) |
int | accept (int s, struct sockaddr *addr, socklen_t *addrlen) |
int | get_sndbuf_size (int s) |
int | get_rcvbuf_size (int s) |
int | set_sndbuf_size (int s, int size) |
int | set_rcvbuf_size (int s, int size) |
int | getsockname (int s, struct sockaddr *, socklen_t *) |
int | close (int sock) |
Close the socket. | |
int | ink_bind (int s, struct sockaddr const *name, int namelen, short protocol=0) |
virtual | ~SocketManager () |
Data Fields | |
const size_t | pagesize |
Utility class for socket operations.
Definition at line 49 of file I_SocketManager.h.
SocketManager::SocketManager | ( | ) |
Definition at line 33 of file SocketManager.cc.
SocketManager::~SocketManager | ( | ) | [virtual] |
Definition at line 38 of file SocketManager.cc.
TS_INLINE int SocketManager::accept | ( | int | s, | |
struct sockaddr * | addr, | |||
socklen_t * | addrlen | |||
) |
Definition at line 63 of file P_UnixSocketManager.h.
References likely, and transient_error().
Referenced by Server::accept(), and NetAccept::acceptFastEvent().
int SocketManager::close | ( | int | sock | ) |
Close the socket.
Definition at line 51 of file SocketManager.cc.
Referenced by DNSConnection::close(), Connection::close(), UDPNetProcessor::CreateUDPSocket(), MultiCacheBase::mmap_data(), read_stats_snap(), UDPNetProcessor::UDPBind(), write_stats_snap(), and UnixUDPConnection::~UnixUDPConnection().
TS_INLINE int SocketManager::dup | ( | int | s | ) |
Definition at line 539 of file P_UnixSocketManager.h.
TS_INLINE int SocketManager::fstat | ( | int | fd, | |
struct stat * | buf | |||
) |
Definition at line 285 of file P_UnixSocketManager.h.
References transient_error().
TS_INLINE int SocketManager::fsync | ( | int | fildes | ) |
Definition at line 308 of file P_UnixSocketManager.h.
TS_INLINE int SocketManager::ftruncate | ( | int | fildes, | |
off_t | length | |||
) |
Definition at line 319 of file P_UnixSocketManager.h.
TS_INLINE int SocketManager::get_rcvbuf_size | ( | int | s | ) |
Definition at line 476 of file P_UnixSocketManager.h.
References safe_getsockopt().
TS_INLINE int SocketManager::get_sndbuf_size | ( | int | s | ) |
Definition at line 465 of file P_UnixSocketManager.h.
References safe_getsockopt().
TS_INLINE int SocketManager::getsockname | ( | int | s, | |
struct sockaddr * | sa, | |||
socklen_t * | sz | |||
) |
Definition at line 499 of file P_UnixSocketManager.h.
int SocketManager::ink_bind | ( | int | s, | |
struct sockaddr const * | name, | |||
int | namelen, | |||
short | protocol = 0 | |||
) |
Definition at line 44 of file SocketManager.cc.
References safe_bind().
Referenced by DNSConnection::connect(), UDPNetProcessor::CreateUDPSocket(), Server::listen(), Connection::open(), Connection::setup_mc_receive(), Connection::setup_mc_send(), and UDPNetProcessor::UDPBind().
TS_INLINE int SocketManager::lockf | ( | int | fildes, | |
int | function, | |||
off_t | size | |||
) |
Definition at line 528 of file P_UnixSocketManager.h.
TS_INLINE int64_t SocketManager::lseek | ( | int | fd, | |
off_t | offset, | |||
int | whence | |||
) |
Definition at line 274 of file P_UnixSocketManager.h.
TS_INLINE int SocketManager::mc_socket | ( | int | domain = AF_INET , |
|
int | type = SOCK_DGRAM , |
|||
int | protocol = 0 , |
|||
bool | bNonBlocking = true | |||
) |
Definition at line 511 of file P_UnixSocketManager.h.
References socket().
Referenced by Connection::setup_mc_send().
TS_INLINE int SocketManager::open | ( | const char * | path, | |
int | oflag = O_RDWR | O_NDELAY | O_CREAT , |
|||
mode_t | mode = DEFAULT_OPEN_MODE | |||
) |
Definition at line 77 of file P_UnixSocketManager.h.
References likely, and transient_error().
Referenced by MultiCacheBase::mmap_data(), open_stats_snap(), and MultiCacheBase::rebuild().
TS_INLINE int SocketManager::poll | ( | struct pollfd * | fds, | |
unsigned long | nfds, | |||
int | timeout | |||
) |
Definition at line 330 of file P_UnixSocketManager.h.
References transient_error().
Referenced by safe_delay(), and send_throttle_message().
TS_INLINE int64_t SocketManager::pread | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
off_t | offset, | |||
char * | tag = NULL | |||
) |
Definition at line 103 of file P_UnixSocketManager.h.
TS_INLINE int64_t SocketManager::pwrite | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
off_t | offset, | |||
char * | tag = NULL | |||
) |
Definition at line 211 of file P_UnixSocketManager.h.
References unlikely.
Referenced by Store::clear().
TS_INLINE int64_t SocketManager::read | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
void * | pOLP = NULL | |||
) |
Definition at line 90 of file P_UnixSocketManager.h.
References likely.
Referenced by read_from_net(), read_stats_snap(), and send_throttle_message().
TS_INLINE int64_t SocketManager::read_vector | ( | int | fd, | |
struct iovec * | vector, | |||
size_t | count, | |||
void * | pOLP = 0 | |||
) |
Definition at line 169 of file P_UnixSocketManager.h.
References vector_io().
TS_INLINE int64_t SocketManager::readv | ( | int | fd, | |
struct iovec * | vector, | |||
size_t | count | |||
) |
Definition at line 115 of file P_UnixSocketManager.h.
References likely, and transient_error().
Referenced by read_from_net(), and vector_io().
TS_INLINE int SocketManager::recv | ( | int | s, | |
void * | buf, | |||
int | len, | |||
int | flags | |||
) |
Definition at line 175 of file P_UnixSocketManager.h.
References unlikely.
TS_INLINE int SocketManager::recvfrom | ( | int | fd, | |
void * | buf, | |||
int | size, | |||
int | flags, | |||
struct sockaddr * | addr, | |||
socklen_t * | addrlen | |||
) |
Definition at line 187 of file P_UnixSocketManager.h.
References unlikely.
Referenced by UDPReadContinuation::readPollEvent(), DNSHandler::recv_dns(), UDPNetProcessor::recvfrom_re(), and UDPNetProcessorInternal::udp_read_from_net().
TS_INLINE int SocketManager::send | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
int | flags | |||
) |
Definition at line 241 of file P_UnixSocketManager.h.
References unlikely.
Referenced by DNSHandler::retry_named(), UnixNetVConnection::send_OOB(), DNSHandler::try_primary_named(), and write_dns_event().
TS_INLINE int SocketManager::sendmsg | ( | int | fd, | |
struct msghdr * | m, | |||
int | flags, | |||
void * | pOLP = 0 | |||
) |
Definition at line 263 of file P_UnixSocketManager.h.
References unlikely.
Referenced by UDPNetProcessor::sendmsg_re().
TS_INLINE int SocketManager::sendto | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
int | flags, | |||
struct sockaddr const * | to, | |||
int | tolen | |||
) |
Definition at line 252 of file P_UnixSocketManager.h.
References unlikely.
TS_INLINE int SocketManager::set_rcvbuf_size | ( | int | s, | |
int | size | |||
) |
Definition at line 493 of file P_UnixSocketManager.h.
References safe_setsockopt().
Referenced by NetAccept::acceptFastEvent(), DNSConnection::connect(), UDPNetProcessor::CreateUDPSocket(), Connection::open(), Server::setup_fd_for_listen(), and UDPNetProcessor::UDPBind().
TS_INLINE int SocketManager::set_sndbuf_size | ( | int | s, | |
int | size | |||
) |
Definition at line 487 of file P_UnixSocketManager.h.
References safe_setsockopt().
Referenced by Server::accept(), NetAccept::acceptFastEvent(), UDPNetProcessor::CreateUDPSocket(), Connection::open(), Server::setup_fd_for_listen(), and UDPNetProcessor::UDPBind().
TS_INLINE int SocketManager::shutdown | ( | int | s, | |
int | how | |||
) |
Definition at line 517 of file P_UnixSocketManager.h.
References unlikely.
Referenced by UnixNetVConnection::do_io_shutdown().
TS_INLINE int SocketManager::socket | ( | int | domain = AF_INET , |
|
int | type = SOCK_STREAM , |
|||
int | protocol = 0 , |
|||
bool | bNonBlocking = true | |||
) |
Definition at line 505 of file P_UnixSocketManager.h.
Referenced by DNSConnection::connect(), UDPNetProcessor::CreateUDPSocket(), Server::listen(), mc_socket(), Connection::open(), Connection::setup_mc_receive(), PrefetchProcessor::start(), and UDPNetProcessor::UDPBind().
TS_INLINE int SocketManager::unlink | ( | char * | buf | ) |
Definition at line 297 of file P_UnixSocketManager.h.
Referenced by clear_stats().
TS_INLINE int64_t SocketManager::vector_io | ( | int | fd, | |
struct iovec * | vector, | |||
size_t | count, | |||
int | read_request, | |||
void * | pOLP = 0 | |||
) |
Definition at line 128 of file P_UnixSocketManager.h.
References likely, min(), readv(), transient_error(), and writev().
Referenced by read_vector(), and write_vector().
TS_INLINE int64_t SocketManager::write | ( | int | fd, | |
void * | buf, | |||
int | len, | |||
void * | pOLP = NULL | |||
) |
Definition at line 199 of file P_UnixSocketManager.h.
References likely.
Referenced by UnixNetVConnection::load_buffer_and_write(), send_throttle_message(), and write_stats_snap().
TS_INLINE int64_t SocketManager::write_vector | ( | int | fd, | |
struct iovec * | vector, | |||
size_t | count, | |||
void * | pOLP = 0 | |||
) |
Definition at line 234 of file P_UnixSocketManager.h.
References vector_io().
TS_INLINE int64_t SocketManager::writev | ( | int | fd, | |
struct iovec * | vector, | |||
size_t | count | |||
) |
Definition at line 222 of file P_UnixSocketManager.h.
References likely, and transient_error().
Referenced by UnixNetVConnection::load_buffer_and_write(), and vector_io().
const size_t SocketManager::pagesize |
Definition at line 125 of file I_SocketManager.h.