Protocols::Transports::UdpSwitch Class Reference

#include <UdpSwitch.h> [code]

Inherits QObject.

Inheritance diagram for Protocols::Transports::UdpSwitch:

Inheritance graph
[legend]
Collaboration diagram for Protocols::Transports::UdpSwitch:

Collaboration graph
[legend]
List of all members.

Detailed Description

Switches packets to / from multiple destinations / sources via a single UDP socket.

This class works in conjunction with a UdpConnection. All data written or read to or from a UdpConnection flows through its associated UdpSwitch. UdpSwitch allows a single UDP socket to be used to comunicate with multiple peers.

Depending on how you start() the switch, you can be nofiied when new incoming connections are detected.

Definition at line 44 of file UdpSwitch.h.

Signals

void connectionAccepted (UdpConnection *)

Public Member Functions

 UdpSwitch ()
 ~UdpSwitch ()
bool start (const NodeAddress &switchAddress, bool acceptIncommingConnection)
 Starts the switch by binding a socket to the given address.
void stop ()

Protected Member Functions

bool openChannel (UdpConnection *udpConnection, const NodeAddress &nodeAddress)
void closeChannel (UdpConnection *udpConnection)
bool writeDatagram (UdpConnection *udpConnection, const char *data, qint64 maxSize)

Private Slots

void readyRead ()

Private Member Functions

 UdpSwitch (const UdpSwitch &)
UdpSwitchoperator= (const UdpSwitch &)

Private Attributes

UdpSwitchPrivatep

Friends

class UdpConnection


Constructor & Destructor Documentation

Protocols::Transports::UdpSwitch::UdpSwitch const UdpSwitch  )  [private]
 

UdpSwitch::UdpSwitch  ) 
 

Definition at line 66 of file UdpSwitch.cpp.

UdpSwitch::~UdpSwitch  ) 
 

Definition at line 72 of file UdpSwitch.cpp.


Member Function Documentation

void UdpSwitch::closeChannel UdpConnection udpConnection  )  [protected]
 

Definition at line 127 of file UdpSwitch.cpp.

void Protocols::Transports::UdpSwitch::connectionAccepted UdpConnection  )  [signal]
 

bool UdpSwitch::openChannel UdpConnection udpConnection,
const NodeAddress nodeAddress
[protected]
 

Definition at line 113 of file UdpSwitch.cpp.

UdpSwitch& Protocols::Transports::UdpSwitch::operator= const UdpSwitch  )  [private]
 

void UdpSwitch::readyRead  )  [private, slot]
 

Definition at line 151 of file UdpSwitch.cpp.

bool UdpSwitch::start const NodeAddress switchAddress,
bool  acceptIncomingConnections
 

Starts the switch by binding a socket to the given address.

This fucntion tries to bind a QUdpSocket at the specified switchAddress. It returns true on success and false on failure.

The argument acceptIncomingConnections specifies whether a new UdpConnection should be created when a packet from yet unseen address is received. If you specify false, such packets will be simply discarded.

If you specidy true, then a new UdpConnection will be created and the read datagram buffered there. Make sure that you connect the signal connectionAccepted(UdpConnection *) to some slot. The receiver of the signal gains ownership of the new UdpConnection object. If you fail to connect the signal and acceptIncomingConnections is true, then some resouced will be leaked.

Definition at line 93 of file UdpSwitch.cpp.

void UdpSwitch::stop  ) 
 

Definition at line 103 of file UdpSwitch.cpp.

bool UdpSwitch::writeDatagram UdpConnection udpConnection,
const char *  data,
qint64  maxSize
[protected]
 

Definition at line 136 of file UdpSwitch.cpp.


Friends And Related Function Documentation

friend class UdpConnection [friend]
 

Definition at line 71 of file UdpSwitch.h.


Member Data Documentation

UdpSwitchPrivate* Protocols::Transports::UdpSwitch::p [private]
 

Definition at line 69 of file UdpSwitch.h.


The documentation for this class was generated from the following files: