#include <UDPSocket.h>
Inheritance diagram for ASSA::UDPSocket:
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.
|
Default constructor.
Definition at line 31 of file UDPSocket.h. References trace. 00032 { 00033 trace("UDPSocket::UDPSocket()"); 00034 }
|
|
Constructor.
Definition at line 39 of file UDPSocket.h. References ASSA::Socket::m_fd, and trace.
|
|
Destructor will close connection.
Definition at line 46 of file UDPSocket.h. References trace. 00047 { 00048 trace("UDPSocket::~UDPSocket"); 00049 }
|
|
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.
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. 00053 { 00054 trace("UDPSocket::bind"); 00055 00056 int ret = ::bind (m_fd, (SA*) my_address_.getAddress(), 00057 my_address_.getLength()); 00058 if (ret < 0) { 00059 setstate (Socket::failbit); 00060 return false; 00061 } 00062 return true; 00063 }
|
|
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. 00040 { 00041 trace("UDPSocket::close()"); 00042 if ( m_fd >= 0 ) { 00043 ::close(m_fd); 00044 setstate (Socket::failbit); 00045 m_fd = -1; 00046 } 00047 return true; 00048 }
|
|
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(). 00077 { return m_type; }
|
|
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(). 00074 { return m_fd; }
|
|
Create socket. Socket domain type is specified as AF_INET for internet socket and AF_UNIX for UNIX domain socket (full duplex pipe).
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. 00023 { 00024 trace("UDPSocket::open"); 00025 00026 m_type = domain_; 00027 m_fd = ::socket (m_type, SOCK_DGRAM, 0); 00028 00029 if (m_fd < 0) { 00030 setstate (Socket::failbit); 00031 return false; 00032 } 00033 clear (); 00034 return true; 00035 }
|
|
Set socket domain type.
Definition at line 84 of file UDPSocket.h. References ASSA::Socket::m_type. 00084 { m_type = type_; }
|
|
Set file descriptor.
Definition at line 81 of file UDPSocket.h. References ASSA::Socket::m_fd. 00081 { m_fd = fd_; }
|