IBR-DTNSuite
0.10
|
#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 61 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 51 of file socket.cpp.
|
protected |
Definition at line 56 of file socket.cpp.
|
protected |
Definition at line 240 of file socket.cpp.
References ibrcommon::vaddress::toString().
Referenced by ibrcommon::tcpserversocket::bind(), ibrcommon::udpsocket::bind(), and ibrcommon::lowpansocket::up().
|
protected |
Definition at line 1279 of file socket.cpp.
|
protected |
Error check methods
Definition at line 1248 of file socket.cpp.
void ibrcommon::basesocket::close | ( | ) | throw (socket_exception) |
Standard socket calls
Definition at line 89 of file socket.cpp.
References _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(), ibrcommon::fileserversocket::up(), ibrcommon::tcpsocket::up(), ibrcommon::tcpserversocket::up(), and ibrcommon::udpsocket::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 69 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 176 of file socket.cpp.
References _family.
Referenced by ibrcommon::multicastsocket::down(), and ibrcommon::multicastsocket::up().
|
static |
Definition at line 181 of file socket.cpp.
|
static |
Checks if the given network protocol is supported
Definition at line 196 of file socket.cpp.
Referenced by dtn::api::ApiServer::ApiServer().
|
protected |
Definition at line 206 of file socket.cpp.
Referenced by ibrcommon::lowpansocket::up(), ibrcommon::filesocket::up(), ibrcommon::fileserversocket::up(), ibrcommon::tcpserversocket::up(), and ibrcommon::udpsocket::up().
|
protected |
Definition at line 232 of file socket.cpp.
bool ibrcommon::basesocket::ready | ( | ) | const |
Definition at line 115 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 75 of file socket.cpp.
References _fd, _state, fd(), SOCKET_DESTROYED, SOCKET_DOWN, and SOCKET_UP.
Referenced by ibrcommon::tcpsocket::up().
|
protected |
Definition at line 120 of file socket.cpp.
Referenced by ibrcommon::serversocket::set(), and ibrcommon::tcpsocket::up().
|
protected |
Definition at line 138 of file socket.cpp.
|
protected |
Definition at line 147 of file socket.cpp.
|
protected |
Definition at line 168 of file socket.cpp.
|
protected |
Definition at line 159 of file socket.cpp.
Referenced by ibrcommon::tcpserversocket::up(), and ibrcommon::udpsocket::up().
void ibrcommon::basesocket::shutdown | ( | int | how | ) | throw (socket_exception) |
Definition at line 103 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 205 of file socket.h.
Referenced by get_family().
|
protected |
Definition at line 202 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 199 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 |