IBR-DTNSuite
0.12
|
#include <socket.h>
Public Member Functions | |
virtual | ~basesocket ()=0 |
virtual void | up ()=0 throw (socket_exception) |
virtual void | down ()=0 throw (socket_exception) |
virtual int | fd () const throw (socket_exception) |
virtual int | release () throw (socket_exception) |
void | close () throw (socket_exception) |
void | shutdown (int how) throw (socket_exception) |
bool | ready () const |
sa_family_t | get_family () const throw (socket_exception) |
Static Public Member Functions | |
static sa_family_t | get_family (int fd) throw (socket_exception) |
static bool | hasSupport (const sa_family_t family, const int type=SOCK_DGRAM, const int protocol=0) throw () |
Static Public Attributes | |
static int | DEFAULT_SOCKET_FAMILY = AF_INET6 |
static int | DEFAULT_SOCKET_FAMILY_ALTERNATIVE = AF_INET |
Protected Types | |
enum | socketstate { SOCKET_DOWN, SOCKET_UP, SOCKET_UNMANAGED, SOCKET_DESTROYED } |
Protected Member Functions | |
basesocket () | |
basesocket (int fd) | |
void | check_socket_error (const int err) const throw (socket_exception) |
void | check_bind_error (const int err, const std::string &msg="") const throw (socket_exception) |
void | set_blocking_mode (bool val, int fd=-1) const throw (socket_exception) |
void | set_keepalive (bool val, int fd=-1) const throw (socket_exception) |
void | set_linger (bool val, int l=1, int fd=-1) const throw (socket_exception) |
void | set_reuseaddr (bool val, int fd=-1) const throw (socket_exception) |
void | set_nodelay (bool val, int fd=-1) const throw (socket_exception) |
void | init_socket (const vaddress &addr, int type, int protocol) throw (socket_exception) |
void | init_socket (int domain, int type, int protocol) throw (socket_exception) |
void | bind (int fd, struct sockaddr *addr, socklen_t len) throw (socket_exception) |
Protected Attributes | |
socketstate | _state |
int | _fd |
sa_family_t | _family |
The basesocket is an interface for all kinds of sockets. The methods allows to bring the socket up or down.
|
protected |
|
pure virtual |
Definition at line 111 of file socket.cpp.
References _fd, _state, SOCKET_DESTROYED, and SOCKET_DOWN.
|
protected |
This is a protected constructor to prevent any direct instantiation.
fd | An existing file descriptor to use. |
Definition at line 99 of file socket.cpp.
References __init_sockets.
|
protected |
Definition at line 105 of file socket.cpp.
References __init_sockets.
|
protected |
Definition at line 296 of file socket.cpp.
References __errno, and ibrcommon::vaddress::toString().
Referenced by ibrcommon::tcpserversocket::bind(), ibrcommon::udpsocket::bind(), and ibrcommon::lowpansocket::up().
|
protected |
Definition at line 1345 of file socket.cpp.
|
protected |
Error check methods
Definition at line 1314 of file socket.cpp.
void ibrcommon::basesocket::close | ( | ) | ||
throw | ( | socket_exception | ||
) |
Standard socket calls
Definition at line 139 of file socket.cpp.
References __close, _fd, _state, fd(), SOCKET_DESTROYED, SOCKET_DOWN, and SOCKET_UNMANAGED.
Referenced by ibrcommon::lowpansocket::down(), dtn::net::inotifysocket::down(), ibrcommon::clientsocket::down(), ibrcommon::filesocket::down(), ibrcommon::fileserversocket::down(), ibrcommon::tcpsocket::down(), ibrcommon::tcpserversocket::down(), ibrcommon::udpsocket::down(), ibrcommon::filesocket::up(), and ibrcommon::tcpsocket::up().
|
pure virtual |
Close and destroy the file descriptor of this socket assignment.
socket_exception | if the action has failed |
Implemented in ibrcommon::multicastsocket, ibrcommon::udpsocket, ibrcommon::tcpserversocket, ibrcommon::tcpsocket, ibrcommon::fileserversocket, ibrcommon::filesocket, ibrcommon::datagramsocket, ibrcommon::serversocket, ibrcommon::clientsocket, dtn::net::inotifysocket, and ibrcommon::lowpansocket.
|
virtual |
Return the file descriptor for this socket.
socket_exception | if no file descriptor is available |
Definition at line 119 of file socket.cpp.
References _fd, _state, SOCKET_DESTROYED, and SOCKET_DOWN.
Referenced by close(), dtn::net::inotifysocket::down(), release(), ibrcommon::vsocket::select(), and ibrcommon::tcpsocket::up().
sa_family_t ibrcommon::basesocket::get_family | ( | ) | const | |
throw | ( | socket_exception | ||
) |
return the family of a socket
Definition at line 232 of file socket.cpp.
References _family.
Referenced by ibrcommon::multicastsocket::down(), dtn::net::IPNDAgent::onAdvertiseBeacon(), and ibrcommon::multicastsocket::up().
|
static |
Definition at line 237 of file socket.cpp.
|
static |
Checks if the given network protocol is supported
Definition at line 252 of file socket.cpp.
References __close.
Referenced by dtn::api::ApiServer::ApiServer().
|
protected |
Definition at line 262 of file socket.cpp.
References __errno.
Referenced by ibrcommon::lowpansocket::up(), ibrcommon::filesocket::up(), ibrcommon::fileserversocket::up(), ibrcommon::tcpserversocket::up(), and ibrcommon::udpsocket::up().
|
protected |
Definition at line 288 of file socket.cpp.
References __errno.
bool ibrcommon::basesocket::ready | ( | ) | const |
Definition at line 165 of file socket.cpp.
References _state, SOCKET_UNMANAGED, and SOCKET_UP.
Referenced by ibrcommon::vsocket::select().
|
virtual |
Return the file descriptor and bring the socket into the down state to keep the file descriptor alive even if the socket object gets destroyed.
Definition at line 125 of file socket.cpp.
References _fd, _state, fd(), SOCKET_DESTROYED, SOCKET_DOWN, and SOCKET_UP.
Referenced by ibrcommon::tcpsocket::up().
|
protected |
Definition at line 170 of file socket.cpp.
Referenced by ibrcommon::serversocket::set(), and ibrcommon::tcpsocket::up().
|
protected |
Definition at line 194 of file socket.cpp.
References __compat_setsockopt.
|
protected |
Definition at line 203 of file socket.cpp.
References __compat_setsockopt.
|
protected |
Definition at line 224 of file socket.cpp.
References __compat_setsockopt.
|
protected |
Definition at line 215 of file socket.cpp.
References __compat_setsockopt.
Referenced by ibrcommon::tcpserversocket::up(), and ibrcommon::udpsocket::up().
void ibrcommon::basesocket::shutdown | ( | int | how) | ||
throw | ( | socket_exception | |||
) |
Definition at line 153 of file socket.cpp.
|
pure virtual |
Create the file descriptor for this socket and bind to the interface if necessary.
socket_exception | if the action has failed |
Implemented in ibrcommon::multicastsocket, ibrcommon::udpsocket, ibrcommon::tcpserversocket, ibrcommon::tcpsocket, ibrcommon::fileserversocket, ibrcommon::filesocket, ibrcommon::datagramsocket, ibrcommon::serversocket, ibrcommon::clientsocket, dtn::net::inotifysocket, and ibrcommon::lowpansocket.
|
protected |
Definition at line 214 of file socket.h.
Referenced by get_family().
|
protected |
Definition at line 211 of file socket.h.
Referenced by close(), ibrcommon::multicastsocket::down(), fd(), release(), ibrcommon::lowpansocket::up(), dtn::net::inotifysocket::up(), ibrcommon::filesocket::up(), ibrcommon::fileserversocket::up(), ibrcommon::tcpsocket::up(), ibrcommon::tcpserversocket::up(), ibrcommon::udpsocket::up(), ibrcommon::multicastsocket::up(), and ~basesocket().
|
protected |
Definition at line 208 of file socket.h.
Referenced by close(), ibrcommon::lowpansocket::down(), dtn::net::inotifysocket::down(), ibrcommon::clientsocket::down(), ibrcommon::filesocket::down(), ibrcommon::fileserversocket::down(), ibrcommon::tcpsocket::down(), ibrcommon::tcpserversocket::down(), ibrcommon::udpsocket::down(), fd(), ready(), release(), ibrcommon::lowpansocket::up(), dtn::net::inotifysocket::up(), ibrcommon::clientsocket::up(), ibrcommon::filesocket::up(), ibrcommon::fileserversocket::up(), ibrcommon::tcpsocket::up(), ibrcommon::tcpserversocket::up(), ibrcommon::udpsocket::up(), and ~basesocket().
|
static |
|
static |