libktorrent  2.1.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
net::PacketSocket Class Reference

#include <packetsocket.h>

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

Public Member Functions

 PacketSocket (bool tcp, int ip_version)
 
 PacketSocket (int fd, int ip_version)
 
 PacketSocket (SocketDevice *sock)
 
void addPacket (bt::Packet::Ptr packet)
 
bool bytesReadyToWrite () const override
 See if the socket has something ready to write.
 
void clearPieces (bool reject)
 
Uint32 dataBytesUploaded ()
 Get the number of data bytes uploaded.
 
void doNotSendPiece (const bt::Request &req, bool reject)
 
Uint32 numPendingPieceUploads () const
 Get the number of pending piece uploads.
 
Uint32 write (Uint32 max, bt::TimeStamp now) override
 
- Public Member Functions inherited from net::TrafficShapedSocket
 TrafficShapedSocket (bool tcp, int ip_version)
 
 TrafficShapedSocket (int fd, int ip_version)
 
 TrafficShapedSocket (SocketDevice *sock)
 
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.
 

Protected Member Functions

virtual void preProcess (bt::Packet::Ptr packet)
 
- Protected Member Functions inherited from net::TrafficShapedSocket
virtual void postProcess (bt::Uint8 *data, bt::Uint32 size)
 

Protected Attributes

std::deque< bt::Packet::Ptr > control_packets
 
Uint32 ctrl_packets_sent
 
bt::Packet::Ptr curr_packet
 
std::deque< bt::Packet::Ptr > data_packets
 
Uint32 uploaded_data_bytes
 
- Protected Attributes inherited from net::TrafficShapedSocket
Uint32 down_gid
 
Speeddown_speed
 
QMutex mutex
 
SocketReaderrdr
 
SocketDevicesock
 
Uint32 up_gid
 
Speedup_speed
 

Detailed Description

Author
Joris Guisson joris.nosp@m..gui.nosp@m.sson@.nosp@m.gmai.nosp@m.l.com

Extends the TrafficShapedSocket with outbound bittorrent packet queues.

Definition at line 62 of file packetsocket.h.

Member Function Documentation

◆ addPacket()

void net::PacketSocket::addPacket ( bt::Packet::Ptr  packet)

Add a packet to send

Parameters
packetThe Packet to send

◆ clearPieces()

void net::PacketSocket::clearPieces ( bool  reject)

Clear all pieces we are not in the progress of sending.

Parameters
rejectWhether or not to send a reject

◆ doNotSendPiece()

void net::PacketSocket::doNotSendPiece ( const bt::Request req,
bool  reject 
)

Do not send a piece which matches this request. But only if we are not already sending the piece.

Parameters
reqThe request
rejectWhether we can send a reject instead

◆ preProcess()

virtual void net::PacketSocket::preProcess ( bt::Packet::Ptr  packet)
protectedvirtual

Preprocess the packet data, before it is sent. Default implementation does nothing.

Parameters
packetThe packet

◆ write()

Uint32 net::PacketSocket::write ( Uint32  max,
bt::TimeStamp  now 
)
overridevirtual

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

Implements net::TrafficShapedSocket.


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