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

Cabal::UDPSocket Class Reference

UDP Socket encapsulation class. More...

#include <cabal_udpsocket.h>

Inheritance diagram for Cabal::UDPSocket:

Inheritance graph
[legend]
Collaboration diagram for Cabal::UDPSocket:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 UDPSocket (const long timeout, const Address *local=0, const Address *remote=0) throw ( InitError )
 UDPSocket (const Address *local=0, const Address *remote=0) throw ( InitError )
 UDPSocket (const char *ip_local, const int port_local) throw ( InitError )
 UDPSocket (const char *ip_local, const int port_local, const char *ip_remote, const int port_remote) throw ( InitError )
bool setBroadcast ()
 Requires broadcast for current socket.

int sendTo (const void *data, const int count, const Address &remote)
 Sends a packet to a determined target.

int recvFrom (void *data, const int count, Address &remote)
 Sends a packet to a determined target.


Protected Member Functions

virtual int rawRecv (void *data, const int len)
 Subclasses hook to receive data.

virtual int rawSend (const void *data, const int len)
 Subclasses hook to send data.


Detailed Description

UDP Socket encapsulation class.

This class encapsulates the behavior of an UDP (and so unconnected) socket. Most notably, it provides broadcast capability and datagram sending.

Definition at line 31 of file cabal_udpsocket.h.


Member Function Documentation

virtual int Cabal::UDPSocket::rawRecv void *  data,
const int  len
[inline, protected, virtual]
 

Subclasses hook to receive data.

This is called by recv() method to allow subclasses to specialize the job. All the preparation and error handling part are done by recv(), subclasses just need to implement this abstract method.

Parameters:
data buffer of data be received.
len maximum length of received data (lenght of the buffer).
Returns:
amount of data received.

Implements Cabal::Socket.

Definition at line 50 of file cabal_udpsocket.h.

References Cabal::Address::varAddress().

virtual int Cabal::UDPSocket::rawSend const void *  data,
const int  len
[inline, protected, virtual]
 

Subclasses hook to send data.

This is called by send() method to allow subclasses to specialize the job. All the preparation and error handling part are done by send(), subclasses just need to implement this abstract method.

Parameters:
data buffer where to get the data to be sent.
len amount of data to be sent.
Returns:
amount of data received.

Implements Cabal::Socket.

Definition at line 60 of file cabal_udpsocket.h.

References Cabal::Address::address().

int Cabal::UDPSocket::recvFrom void *  data,
const int  count,
Address remote
 

Sends a packet to a determined target.

This function works exactly as Socket::recv(), but it does not use the internally stored the remote address. Instead, it uses an address provided as a parameter.

Definition at line 68 of file ltlib/cabal_udpsocket.cpp.

References Cabal::Address::varAddress().

int Cabal::UDPSocket::sendTo const void *  data,
const int  count,
const Address remote
 

Sends a packet to a determined target.

This function works exactly as Socket::send(), but it does not use the internally stored the remote address. Instead, it uses an address provided as a parameter.

Definition at line 47 of file ltlib/cabal_udpsocket.cpp.

References Cabal::Address::address().

bool Cabal::UDPSocket::setBroadcast  ) 
 

Requires broadcast for current socket.

This prepares the current UDP socket to send broadcast requests on its network. Usually, only locally bound sockets can be used to broadcast. The remote address of a broadcast socket can be a specific host or a network address. In the latter case, all the hosts in the target network will receive the packet.

Returns:
false if the current socket cannot be made broadcastable, true on success.

Definition at line 35 of file ltlib/cabal_udpsocket.cpp.


The documentation for this class was generated from the following files:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5