#include <UnConUDPSocket.h>
Inheritance diagram for ASSA::UnConUDPSocket:
Public Member Functions | |
UnConUDPSocket () | |
Constructor. | |
~UnConUDPSocket () | |
Destructor. | |
int | recvfrom (char *buf_, int size_, Address *peer_addr_) |
recvfrom() function receives a message from connectionless-mode socket. | |
int | sendto (const char *buf_, const unsigned int size_, const Address *dest_addr_) |
sendto() function sends a message through connectionless-mode socket. | |
virtual int | in_avail () const |
This function returns the number of characters immediately available in the get area of the underlying Socketbuf buffer without making a system call. |
Definition at line 26 of file UnConUDPSocket.h.
|
Constructor.
Definition at line 70 of file UnConUDPSocket.h. References ASSA::SOCKTRACE, and trace_with_mask. 00070 : UDPSocket() 00071 { 00072 trace_with_mask ("UnConUDPSocket::UnConUDPSocket", SOCKTRACE); 00073 }
|
|
Destructor.
Definition at line 76 of file UnConUDPSocket.h. References ASSA::SOCKTRACE, and trace_with_mask. 00077 { 00078 trace_with_mask ("UnConUDPSocket::~UnConUDPSocket", SOCKTRACE); 00079 }
|
|
This function returns the number of characters immediately available in the get area of the underlying Socketbuf buffer without making a system call. Always return 0. Implements ASSA::Socket. Definition at line 66 of file UnConUDPSocket.h.
|
|
recvfrom() function receives a message from connectionless-mode socket. It also permits the application to retrieve the source address of received data.
Definition at line 25 of file UnConUDPSocket.cpp. References ASSA::Address::getAddress(), ASSA::UDPSocket::getHandler(), and ASSA::Address::getLength(). 00026 { 00027 // ::recvfrom() can return 0 bytes which is not 00028 // considered an eof. Peer can advertise its address to 00029 // the server by sending 0 bytes length message. 00030 // 00031 00032 // char self[] = "Socket::recvfro"; trace(self); 00033 00034 // Setting saddr_len is crucial to proper ::recvfrom() operation. 00035 // If left improprely initialized, ::recvfrom() won't fill in peer's 00036 // address and won't report an error either. If SA ptr is passed to 00037 // recvfrom() along with uninitialized address len (or set to 0), 00038 // recvfrom() returns zeroed out address structure!!! 00039 00040 int len; 00041 socklen_t pa_len = peer_addr_->getLength(); 00042 00043 SA* pa = peer_addr_->getAddress(); 00044 00045 #if defined (__CYGWIN32__) || defined (WIN32) 00046 len = ::recvfrom(getHandler(), buf_, size_, 0, pa, (int*)&pa_len); 00047 #else // posix/unix 00048 len = ::recvfrom(getHandler(), buf_, size_, 0, pa, &pa_len); 00049 #endif 00050 00051 // Q: for UNIX domain socket, returned length will be essential to 00052 // remember and probably should be set in peer_addr_ by calling 00053 // setLength()..... 00054 00055 return len; 00056 }
|
|
sendto() function sends a message through connectionless-mode socket. The message will be sent to the address specified by dest_addr_.
Definition at line 60 of file UnConUDPSocket.cpp. References ASSA::Address::getAddress(), ASSA::UDPSocket::getHandler(), and ASSA::Address::getLength(). 00061 { 00062 return ::sendto (getHandler(), buf_, size_, 0, 00063 peer_addr_->getAddress(), 00064 peer_addr_->getLength()); 00065 }
|