libktorrent  2.2.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
net::TrafficShapedSocket Class Referenceabstract

#include <trafficshapedsocket.h>

Inheritance diagram for net::TrafficShapedSocket:
Inheritance graph
[legend]

Public Member Functions

 TrafficShapedSocket (bool tcp, int ip_version)
 
 TrafficShapedSocket (int fd, int ip_version)
 
 TrafficShapedSocket (SocketDevice *sock)
 
virtual bool bytesReadyToWrite () const =0
 See if the socket has something ready to write.
 
Uint32 downloadGroupID () const
 Get the download group ID.
 
int getDownloadRate () const
 Get the current download rate.
 
int getUploadRate () const
 Get the current download rate.
 
virtual Uint32 read (Uint32 max_bytes_to_read, bt::TimeStamp now)
 
void setGroupID (Uint32 gid, bool upload)
 
void setReader (SocketReader *r)
 Set the reader.
 
SocketDevicesocketDevice ()
 Get the SocketDevice.
 
const SocketDevicesocketDevice () const
 Get the SocketDevice (const vesion)
 
void updateSpeeds (bt::TimeStamp now)
 Update up and down speed.
 
Uint32 uploadGroupID () const
 Get the upload group ID.
 
virtual Uint32 write (Uint32 max, bt::TimeStamp now)=0
 

Protected Member Functions

virtual void postProcess (bt::Uint8 *data, bt::Uint32 size)
 

Protected Attributes

Uint32 down_gid
 
Speeddown_speed
 
QMutex mutex
 
SocketReaderrdr
 
SocketDevicesock
 
Uint32 up_gid
 
Speedup_speed
 

Detailed Description

Socket which supports traffic shaping

Definition at line 51 of file trafficshapedsocket.h.

Member Function Documentation

◆ postProcess()

virtual void net::TrafficShapedSocket::postProcess ( bt::Uint8 *  data,
bt::Uint32  size 
)
protectedvirtual

Post process received data. Default implementation does nothing.

Parameters
dataThe data
sizeThe size of the data

◆ read()

virtual Uint32 net::TrafficShapedSocket::read ( Uint32  max_bytes_to_read,
bt::TimeStamp  now 
)
virtual

Reads data from the socket and pass it to the SocketReader.

Parameters
max_bytes_to_readMaximum number of bytes to read (0 is no limit)
nowCurrent time stamp
Returns
The number of bytes read

◆ setGroupID()

void net::TrafficShapedSocket::setGroupID ( Uint32  gid,
bool  upload 
)

Set the group ID of the socket

Parameters
gidTHe ID (0 is default group)
uploadWhether this is an upload group or a download group

◆ write()

virtual Uint32 net::TrafficShapedSocket::write ( Uint32  max,
bt::TimeStamp  now 
)
pure virtual

Writes data to the socket. Subclasses should implement the data source.

Parameters
maxThe maximum number of bytes to send over the socket (0 = no limit)
nowCurrent time stamp
Returns
The number of bytes written

Implemented in net::PacketSocket.


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