Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Classes | Public Member Functions | Protected Attributes | List of all members
transport::interface::ConsumerSocket Class Reference

Main interface for consumer applications. More...

#include <socket_consumer.h>

Inheritance diagram for transport::interface::ConsumerSocket:
Inheritance graph
[legend]

Classes

class  ReadCallback
 

Public Member Functions

 ConsumerSocket (int protocol)
 Create a new consumer socket. More...
 
 ConsumerSocket (int protocol, asio::io_service &io_service)
 Create a new consumer socket, passing an io_service to it. Passing an io_service means that the caller must explicitely call io_service.run() for the consumer to start. Any call to consume won't be blocking. This can be used in case we want to share a single thread among multiple consumer sockets. The caller MUST ensure the provided io_service will outlive the ConsumerSocket. More...
 
 ~ConsumerSocket ()
 Destroy the consumer socket.
 
void connect ()
 Connect the consumer socket to the underlying hICN forwarder.
 
bool isRunning ()
 Check whether consumer socket is active or not.
 
int consume (const Name &name)
 
int asyncConsume (const Name &name)
 
void stop ()
 
void resume ()
 
asio::io_service & getIoService ()
 
int setSocketOption (int socket_option_key, ReadCallback *socket_option_value)
 
int getSocketOption (int socket_option_key, ReadCallback **socket_option_value)
 
int setSocketOption (int socket_option_key, double socket_option_value)
 
int setSocketOption (int socket_option_key, uint32_t socket_option_value)
 
int setSocketOption (int socket_option_key, std::nullptr_t socket_option_value)
 
int setSocketOption (int socket_option_key, bool socket_option_value)
 
int setSocketOption (int socket_option_key, ConsumerContentObjectCallback socket_option_value)
 
int setSocketOption (int socket_option_key, ConsumerInterestCallback socket_option_value)
 
int setSocketOption (int socket_option_key, interface::IcnObserver *socket_option_value)
 
int setSocketOption (int socket_option_key, const std::shared_ptr< auth::Verifier > &socket_option_value)
 
int setSocketOption (int socket_option_key, const std::string &socket_option_value)
 
int setSocketOption (int socket_option_key, ConsumerTimerCallback socket_option_value)
 
int getSocketOption (int socket_option_key, double &socket_option_value)
 
int getSocketOption (int socket_option_key, uint32_t &socket_option_value)
 
int getSocketOption (int socket_option_key, bool &socket_option_value)
 
int getSocketOption (int socket_option_key, Name **socket_option_value)
 
int getSocketOption (int socket_option_key, ConsumerContentObjectCallback **socket_option_value)
 
int getSocketOption (int socket_option_key, ConsumerInterestCallback **socket_option_value)
 
int getSocketOption (int socket_option_key, IcnObserver **socket_option_value)
 
int getSocketOption (int socket_option_key, std::shared_ptr< auth::Verifier > &socket_option_value)
 
int getSocketOption (int socket_option_key, std::string &socket_option_value)
 
int getSocketOption (int socket_option_key, ConsumerTimerCallback **socket_option_value)
 
int getSocketOption (int socket_option_key, interface::TransportStatistics **socket_option_value)
 

Protected Attributes

std::unique_ptr< implementation::ConsumerSocketsocket_
 

Detailed Description

Main interface for consumer applications.

The consumer socket is the main interface for a consumer application. It allows to retrieve an application data from one/many producers, by hiding all the complexity of the transport protocol used underneath.

Constructor & Destructor Documentation

◆ ConsumerSocket() [1/2]

transport::interface::ConsumerSocket::ConsumerSocket ( int  protocol)
explicit

Create a new consumer socket.

Parameters
protocol- The transport protocol to use. So far the following transport are supported:
  • CBR: Constant bitrate
  • RAAQM: Based on paper: Optimal multipath congestion control and request forwarding in information-centric networks: Protocol design and experimentation. G Carofiglio, M Gallo, L Muscariello. Computer Networks 110, 104-117
  • RTC: Real time communication

◆ ConsumerSocket() [2/2]

transport::interface::ConsumerSocket::ConsumerSocket ( int  protocol,
asio::io_service &  io_service 
)
explicit

Create a new consumer socket, passing an io_service to it. Passing an io_service means that the caller must explicitely call io_service.run() for the consumer to start. Any call to consume won't be blocking. This can be used in case we want to share a single thread among multiple consumer sockets. The caller MUST ensure the provided io_service will outlive the ConsumerSocket.

Parameters
protocol- The transport protocol to use. So far the following transport are supported:
  • CBR: Constant bitrate
  • RAAQM: Based on paper: Optimal multipath congestion control and request forwarding in information-centric networks: Protocol design and experimentation. G Carofiglio, M Gallo, L Muscariello. Computer Networks 110, 104-117
  • RTC: Real time communication

Member Function Documentation

◆ consume()

int transport::interface::ConsumerSocket::consume ( const Name name)

Retrieve a content using the protocol specified in the constructor. This function blocks until the whole content is downloaded. For monitoring the status of the download, the application MUST set the ConsumerRead callback. This callback will be called periodically (depending on the needs of the application), allowing the application to save the retrieved data.

Parameters
name- The name of the content to retrieve.
Returns
CONSUMER_BUSY if a pending download exists
CONSUMER_FINISHED when the download finishes

Notice that the fact consume() returns CONSUMER_FINISHED does not imply the content retrieval succeeded. This information can be obtained from the error code in CONTENT_RETRIEVED callback.

◆ getIoService()

asio::io_service& transport::interface::ConsumerSocket::getIoService ( )

Get the io_service which is running the transport protocol event loop.

Returns
A reference to the internal io_service where the transport protocol is running.

◆ resume()

void transport::interface::ConsumerSocket::resume ( )

Resume the download from the same exact point it stopped.

◆ stop()

void transport::interface::ConsumerSocket::stop ( )

Stops the consumer socket. If several downloads are queued (using asyncConsume), this call stops just the current one.


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