ns-3
ns3::FdReader Class Reference

A class that asynchronously reads from a file descriptor. More...

#include <unix-fd-reader.h>

Inheritance diagram for ns3::FdReader:
Collaboration diagram for ns3::FdReader:

List of all members.

Classes

struct  Data

Public Member Functions

void Start (int fd, Callback< void, uint8_t *, ssize_t > readCallback)
void Stop (void)
- Public Member Functions inherited from ns3::SimpleRefCount< FdReader >
 SimpleRefCount (const SimpleRefCount &o)
SimpleRefCountoperator= (const SimpleRefCount &o)
void Ref (void) const
void Unref (void) const
uint32_t GetReferenceCount (void) const

Protected Member Functions

virtual FdReader::Data DoRead (void)=0

Protected Attributes

int m_fd

Additional Inherited Members

- Static Public Member Functions inherited from ns3::SimpleRefCount< FdReader >
static void Cleanup (void)

Detailed Description

A class that asynchronously reads from a file descriptor.

This class can be used to start a system thread that reads from a given file descriptor and invokes a given callback when data is received. This class handles thread management automatically but the DoRead() method must be implemented by a subclass.


Member Function Documentation

void ns3::FdReader::Start ( int  fd,
Callback< void, uint8_t *, ssize_t >  readCallback 
)

Start a new read thread.

Parameters:
fdA valid file descriptor open for reading.
readCallbackA callback to invoke when new data is available.

References ns3::EventId::IsRunning(), ns3::MakeCallback(), NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_LOGIC, ns3::SimpleRefCount< FdReader >::Ref(), ns3::Simulator::ScheduleDestroy(), and ns3::SystemThread::Start().

void ns3::FdReader::Stop ( void  )

Stop the read thread and reset internal state. This does not close the file descriptor used for reading.

References ns3::SystemThread::Join(), and NS_LOG_WARN.


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