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

RefCountingSocket Class Reference

#include <RefCountingSocket.h>

Inheritance diagram for RefCountingSocket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 RefCountingSocket (const RefCountingSocket &)
 RefCountingSocket (MNSelector &sel, MNSocket &sock)
 RefCountingSocket (MNSelector &sel, int port)
virtual ~RefCountingSocket ()
void startUdpServer (bool sender)
void stopUdpServer ()
virtual int reader (MNRope *&rope, struct sockaddr_in *&dest)=0
virtual void writer ()=0
bool join_multicast (int port, const char *address)
bool is_multicast_joined () const
void set_multicast_ttl (int val)
int get_multicast_ttl ()
int get_descriptor ()
void set_multicast_if (const char *ifname)
int send (struct iovec *iov, size_t iov_size, int target_port, const char *target_addr)
int send (MNRope *rope, const struct sockaddr_in &target_addr)
int send (struct iovec *iov, size_t iov_size, const struct sockaddr_in &target_addr)
MNSelectorgetSelector ()

Detailed Description

This class implements a UDP/TCP socket that is shared by several objects. The destructor is not thread-safe. See the destructor preconditions.


Constructor & Destructor Documentation

RefCountingSocket::RefCountingSocket const RefCountingSocket  ) 
 

RefCountingSocket::RefCountingSocket MNSelector sel,
MNSocket sock
 

RefCountingSocket::RefCountingSocket MNSelector sel,
int  port
 

virtual RefCountingSocket::~RefCountingSocket  )  [virtual]
 

Destructor. This destructor is not thread-safe. The socket has been deactivated. The application is responsible for preventing write access to the object when the destructor is called. Arrival of data should be deactivated before this function is call using the stopUDPServer()/stopTCPServer() method explicitly (although it will be called in the destructor as well.


Member Function Documentation

int RefCountingSocket::get_descriptor  ) 
 

int RefCountingSocket::get_multicast_ttl  ) 
 

Retrieve the current TTL value.

Returns:
The TTL value.

MNSelector& RefCountingSocket::getSelector  ) 
 

Returns the selector of the MNUDPServerSocket/MNTCPServerSocket socket that is actually used. The selector can be reuse by other objects that need to wait for sockets.

bool RefCountingSocket::is_multicast_joined  )  const
 

bool RefCountingSocket::join_multicast int  port,
const char *  address
 

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

Called when data is received.

See also:
MNUDPSocket

Implemented in MNRTPbase.

int RefCountingSocket::send struct iovec *  iov,
size_t  iov_size,
const struct sockaddr_in &  target_addr
 

Send the array of iovec structures to the given addr.

Parameters:
iov An array of iovec structure containing the buffers to be sent.
iov_size The number of entries in the iovec array.
target_addr The resolved destination address.
Returns:
The number of bytes send or -1 in case of an error.

int RefCountingSocket::send MNRope rope,
const struct sockaddr_in &  target_addr
 

Send the rope to the given addr.

Parameters:
rope A rope containing strings that are logically concatenated and shall be sent as a single buffer.
target_addr The resolved destination address.
Returns:
The number of bytes send or -1 in case of an error.

int RefCountingSocket::send struct iovec *  iov,
size_t  iov_size,
int  target_port,
const char *  target_addr
 

void RefCountingSocket::set_multicast_if const char *  ifname  ) 
 

Change the default interface for multicast packets.

Parameters:
ifname The new default interface.

void RefCountingSocket::set_multicast_ttl int  val  ) 
 

Change the current TTL value.

Parameters:
val The new TTL value

void RefCountingSocket::startUdpServer bool  sender  ) 
 

Creates the thread in RefCountedSocket, if it does not exist yet.

void RefCountingSocket::stopUdpServer  ) 
 

Terminates the reception of data. After this call, the socket can not be restarted and should be deleted. The call blocks the calling thread until it is safe to assume that no more data will arrive. It is safe to delete the object.

virtual void RefCountingSocket::writer  )  [pure virtual]
 

Implemented in MNRTPbase.


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