libassa
3.5.0
|
#include <UDPSocket.h>
Public Member Functions | |
UDPSocket () | |
Default constructor. | |
UDPSocket (const handler_t fd_) | |
Constructor. | |
virtual | ~UDPSocket () |
Destructor will close connection. | |
bool | open (const int domain_) |
Create socket. | |
bool | close () |
Close socket connection. | |
bool | bind (const Address &my_address_) |
Server in UDP client-server scenario has to bind socket to its local well-known port. | |
handler_t | getHandler () const |
Get socket file descriptor. | |
const int | getDomain () const |
Get socket domain type. | |
Protected Member Functions | |
void | setHandler (const int fd_) |
Set file descriptor. | |
void | setDomain (const int type_) |
Set socket domain type. |
Definition at line 28 of file UDPSocket.h.
ASSA::UDPSocket::UDPSocket | ( | ) | [inline] |
Default constructor.
Definition at line 31 of file UDPSocket.h.
References trace.
{ trace("UDPSocket::UDPSocket()"); }
ASSA::UDPSocket::UDPSocket | ( | const handler_t | fd_ | ) | [inline] |
Constructor.
fd_ | file descriptor to use |
Definition at line 39 of file UDPSocket.h.
References ASSA::Socket::m_fd, and trace.
virtual ASSA::UDPSocket::~UDPSocket | ( | ) | [inline, virtual] |
Destructor will close connection.
Definition at line 46 of file UDPSocket.h.
References trace.
{ trace("UDPSocket::~UDPSocket"); }
bool UDPSocket::bind | ( | const Address & | my_address_ | ) | [virtual] |
Server in UDP client-server scenario has to bind socket to its local well-known port.
This is the same bind call as in IPv4 - maybe it should be generalized in parent class.
my_address_ | address to bind to |
Implements ASSA::Socket.
Definition at line 52 of file UDPSocket.cpp.
References ASSA::Socket::failbit, ASSA::Address::getAddress(), ASSA::Address::getLength(), ASSA::Socket::m_fd, ASSA::Socket::setstate(), and trace.
{ trace("UDPSocket::bind"); int ret = ::bind (m_fd, (SA*) my_address_.getAddress(), my_address_.getLength()); if (ret < 0) { setstate (Socket::failbit); return false; } return true; }
bool UDPSocket::close | ( | void | ) | [virtual] |
Close socket connection.
Implements ASSA::Socket.
Definition at line 39 of file UDPSocket.cpp.
References ASSA::Socket::failbit, ASSA::Socket::m_fd, ASSA::Socket::setstate(), and trace.
const int ASSA::UDPSocket::getDomain | ( | ) | const [inline, virtual] |
Get socket domain type.
Implements ASSA::Socket.
Definition at line 77 of file UDPSocket.h.
References ASSA::Socket::m_type.
Referenced by ASSA::ConUDPSocket::unconnect().
{ return m_type; }
handler_t ASSA::UDPSocket::getHandler | ( | ) | const [inline, virtual] |
Get socket file descriptor.
Implements ASSA::Socket.
Definition at line 74 of file UDPSocket.h.
References ASSA::Socket::m_fd.
Referenced by ASSA::ConUDPSocket::connect(), ASSA::ConUDPSocket::read(), ASSA::UnConUDPSocket::recvfrom(), ASSA::UnConUDPSocket::sendto(), and ASSA::ConUDPSocket::write().
{ return m_fd; }
bool UDPSocket::open | ( | const int | domain_ | ) | [virtual] |
Create socket.
Socket domain type is specified as AF_INET for internet socket and AF_UNIX for UNIX domain socket (full duplex pipe).
domain_ | domain |
Implements ASSA::Socket.
Definition at line 22 of file UDPSocket.cpp.
References ASSA::Socket::clear(), ASSA::Socket::failbit, ASSA::Socket::m_fd, ASSA::Socket::m_type, ASSA::Socket::setstate(), and trace.
void ASSA::UDPSocket::setDomain | ( | const int | type_ | ) | [inline, protected] |
Set socket domain type.
Definition at line 84 of file UDPSocket.h.
References ASSA::Socket::m_type.
{ m_type = type_; }
void ASSA::UDPSocket::setHandler | ( | const int | fd_ | ) | [inline, protected] |
Set file descriptor.
Definition at line 81 of file UDPSocket.h.
References ASSA::Socket::m_fd.
{ m_fd = fd_; }