Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNUDPSocket Class Reference

#include <MNUDPSocket.h>

Inheritance diagram for MNUDPSocket:

Inheritance graph
[legend]
Collaboration diagram for MNUDPSocket:

Collaboration graph
[legend]
List of all members.

Public Types

enum  CallbackMode { ClientMode, IovecMode, RopeMode }

Public Member Functions

 MNUDPSocket (MNSocket &orig, int copyflags)
 MNUDPSocket (CallbackSetting cm, MNSocket &orig, int copyflags)
 MNUDPSocket (CallbackSetting cm)
 MNUDPSocket (CallbackSetting cm, int sockfd)
virtual ~MNUDPSocket ()
virtual void callback (MNSelector *select, int fd)
virtual bool isUdp () const
bool join_mc (int port, const char *hostname, char *ifnamei, int onoff)
virtual struct iovec * set_buffers (int &iovlen)
virtual void unset_buffers (struct iovec *iov, int iovlen)
MNRopebuffers_to_rope (struct iovec *iov, int &iovlen, size_t bytesused)
int recvfrom (char *buffer, int buflen)
int recvfrom (char *buffer, int buflen, struct sockaddr_in &sock_addr, unsigned &sock_size)
int sendto (const void *buf, int buflen, const struct sockaddr_in *server_addr)
int sendto (const char *buff, int len, int port, const char *hostname)
virtual int reader (struct iovec *iov, int len, struct sockaddr_in *&dest)=0
virtual void writer ()=0
virtual int reader (MNRope *&rope, struct sockaddr_in *&dest)=0
void connect (int port, char *hostname)

Protected Member Functions

CallbackMode cm () const

Member Enumeration Documentation

enum MNUDPSocket::CallbackMode
 

Enumeration values:
ClientMode 
IovecMode 
RopeMode 


Constructor & Destructor Documentation

MNUDPSocket::MNUDPSocket MNSocket orig,
int  copyflags
 

MNUDPSocket::MNUDPSocket CallbackSetting  cm,
MNSocket orig,
int  copyflags
 

MNUDPSocket::MNUDPSocket CallbackSetting  cm  ) 
 

MNUDPSocket::MNUDPSocket CallbackSetting  cm,
int  sockfd
 

virtual MNUDPSocket::~MNUDPSocket  )  [virtual]
 


Member Function Documentation

MNRope* MNUDPSocket::buffers_to_rope struct iovec *  iov,
int &  iovlen,
size_t  bytesused
 

virtual void MNUDPSocket::callback MNSelector select,
int  fd
[virtual]
 

Reimplemented from MNSocketBase.

CallbackMode MNUDPSocket::cm  )  const [inline, protected]
 

void MNUDPSocket::connect int  port,
char *  hostname
 

virtual bool MNUDPSocket::isUdp  )  const [inline, virtual]
 

Simple function returning true. It is used to figure out what kind of socket is used. This is a UDP class so the function returns true

Returns:
Always true since this is a UDP socket class

Implements MNSocket.

bool MNUDPSocket::join_mc int  port,
const char *  hostname,
char *  ifnamei,
int  onoff
 

Try to join the given multicast address on the given interface. This is shortcut function for several functions in MNSocket.

Parameters:
port The port to join.
hostname The multicast address to join.
ifnamei The name of the local interface that should join the group.
onoff Set to true to activate receiving packets sent from the same host. Set to false to forbid it.
Return values:
true Successfully initiated a join.
false Failed to join.

virtual int MNUDPSocket::reader MNRope *&  rope,
struct sockaddr_in *&  dest
[pure virtual]
 

Pure virtual function to be overloaded by child classes for receiving data.
Overloaded by child class to receive data that has arrived in buffer that were previously allocated by the caller and passed to the MNSocket in the set_buffers() virtual function.

Parameters:
rope An MNRope structure that contains the receive data chunks and allows the access to these chunks in the same manner as a flat buffer, it support copy-on-write and multiple references to the same data. It is efficient for the callee to keep the rope structure. If it does, the rope parameter must be NULL on return. The callee assumes responsibility for releasing the data in that case. Otherwise, the data is released on return.
dest A sockaddr_in structure containing information about the UDP packet's sender. It is allocated by MNUDPSocket. If the overloading function releases this memory, or if it intends to keep the data, it must set dest=NULL before returning from reader().
Returns:
Should return the number of bytes read.

Implemented in MNUDPClientSocket.

virtual int MNUDPSocket::reader struct iovec *  iov,
int  len,
struct sockaddr_in *&  dest
[pure virtual]
 

Pure virtual function to be overloaded by child classes for receiving data.
Overloaded by child class to receive data that has arrived in buffer that were previously allocated by the caller and passed to the MNSocket in the set_buffers() virtual function.

Parameters:
iov Iovec array that has been allocated by a child class in set_buffers. It contains the data, if any.
len The number of bytes read.
dest A sockaddr_in structure containing information about the UDP packet's sender. It is allocated by MNUDPSocket. If the overloading function releases this memory, or if it intends to keep the data, it must set dest=NULL before returning from reader().
Returns:
Should return the number of bytes read.

Implemented in MNUDPClientSocket.

int MNUDPSocket::recvfrom char *  buffer,
int  buflen,
struct sockaddr_in &  sock_addr,
unsigned &  sock_size
 

int MNUDPSocket::recvfrom char *  buffer,
int  buflen
 

int MNUDPSocket::sendto const char *  buff,
int  len,
int  port,
const char *  hostname
 

int MNUDPSocket::sendto const void *  buf,
int  buflen,
const struct sockaddr_in *  server_addr
 

virtual struct iovec* MNUDPSocket::set_buffers int &  iovlen  )  [virtual]
 

virtual void MNUDPSocket::unset_buffers struct iovec *  iov,
int  iovlen
[virtual]
 

virtual void MNUDPSocket::writer  )  [pure virtual]
 

Implemented in MNUDPClientSocket.


The documentation for this class was generated from the following file:
Generated on Sun Mar 6 13:36:03 2005 for Komssys by doxygen 1.3.8