fipa_services
Public Member Functions | List of all members
fipa::services::transports::udt::UDTTransport Class Reference

A UDTTransport provides a server that allows to establish udt connection to transfer fipa::acl::Letter. More...

#include <UDTTransport.hpp>

Inheritance diagram for fipa::services::transports::udt::UDTTransport:
fipa::services::transports::Transport

Public Member Functions

 UDTTransport ()
 
 ~UDTTransport ()
 
void start ()
 
virtual void update (bool readAllMessages=true)
 
Address getAddress (const std::string &interfaceName="eth0") const
 
virtual OutgoingConnection::Ptr establishOutgoingConnection (const Address &address)
 
- Public Member Functions inherited from fipa::services::transports::Transport
virtual ~Transport ()
 
void registerObserver (TransportObserver observer)
 
Type getType () const
 
std::string getName () const
 
void send (const std::string &receiverName, const Address &address, const std::string &data)
 
std::set< AddressgetAddresses () const
 
OutgoingConnection::Ptr getCachedOutgoingConnection (const std::string &receiverName, const Address &address)
 
void cleanup (const std::string &receiver)
 
void notify (const std::string &message)
 
void setConfiguration (const Configuration &configuration)
 
const ConfigurationgetConfiguration () const
 

Additional Inherited Members

- Public Types inherited from fipa::services::transports::Transport
enum  Type { UNKNOWN = 0x00, UDT = 0x01, TCP = 0x02, ALL = 0xFF }
 Builtin transport types that can be activated. More...
 
typedef boost::shared_ptr< TransportPtr
 
- Static Public Member Functions inherited from fipa::services::transports::Transport
static Transport::Ptr create (Type type)
 
static Type getTypeFromTxt (const std::string &typeTxt)
 
static std::string getLocalIPv4Address (const std::string &interfaceName="eth0")
 
- Static Public Attributes inherited from fipa::services::transports::Transport
static std::map< Type, std::string > TypeTxt
 
- Protected Member Functions inherited from fipa::services::transports::Transport
 Transport (Type type)
 
 Transport (const Configuration &configuration)
 
- Protected Attributes inherited from fipa::services::transports::Transport
Configuration mConfiguration
 

Detailed Description

A UDTTransport provides a server that allows to establish udt connection to transfer fipa::acl::Letter.

The implementation is caching all incoming messages in an internal queue until they are handle by calling UDTTransport::nextLetter Very basic example for a receiver node:

#include <fipa_services/transports/udt/UDTTransport.hpp>

using namespace fipa::services;
udt::UDTTransport node;

// start node -- if no port is give it will be autoassigned and can be requested
// by node.getAddress() afterwards.
node.listen(2000);

while(true)
{
    // accept new connections
    node.accept();

    // Handle message transfers/reading new data
    node.update();
    while(node.hasLetter())
    {
        fipa::acl::Letter letter = node.nextLetter();
        // process letter
    }

    sleep(0.05);
}

A very basic example for a sender:

#include <fipa_services/transports/udt/UDTTransport.hpp>
// the address has to be known
udt::Adress address("127.0.0.1","2000");

// --------- Sender ------------
//
udt::OutgoingConnection connection(address);
fipa::acl::ACLMessage msg;
msg.setContent("test-content");
fipa::acl::Letter letter(msg, fipa::acl::representation::STRING_REP);
connection.sendLetter(letter);

Constructor & Destructor Documentation

fipa::services::transports::udt::UDTTransport::UDTTransport ( )
fipa::services::transports::udt::UDTTransport::~UDTTransport ( )

Member Function Documentation

OutgoingConnection::Ptr fipa::services::transports::udt::UDTTransport::establishOutgoingConnection ( const Address address)
virtual

Create a udt based outgoing connection

Reimplemented from fipa::services::transports::Transport.

Address fipa::services::transports::udt::UDTTransport::getAddress ( const std::string &  interfaceName = "eth0") const
virtual

Get address of this node for a given interface

Parameters
interfaceNamename of the interface, default is eth0
Returns
address of the node

Reimplemented from fipa::services::transports::Transport.

void fipa::services::transports::udt::UDTTransport::start ( )
virtual

Start transport functionality, e.g. listen socket etc.

Reimplemented from fipa::services::transports::Transport.

void fipa::services::transports::udt::UDTTransport::update ( bool  readAllMessages = true)
virtual

Update and read all sockets

Parameters
readAllMessagesIf set to true, update will return only when no further message can be read from any of the IncomingConnections. If set to false all connections will be checked only once for new messages

Reimplemented from fipa::services::transports::Transport.


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