Public Member Functions | List of all members
SOCKS5Bytestream Class Reference

#include <socks5bytestream.h>

Inheritance diagram for SOCKS5Bytestream:
Inheritance graph
Collaboration diagram for SOCKS5Bytestream:
Collaboration graph

Public Member Functions

virtual ~SOCKS5Bytestream ()
bool isOpen () const
bool connect ()
void close ()
bool send (const std::string &data)
ConnectionError recv (int timeout=-1)
const std::string & sid () const
const JIDtarget () const
const JIDinitiator () const
void setConnectionImpl (ConnectionBase *connection)
ConnectionBaseconnectionImpl ()
void setStreamHosts (const StreamHostList &hosts)
void registerSOCKS5BytestreamDataHandler (SOCKS5BytestreamDataHandler *s5bdh)
void removeSOCKS5BytestreamDataHandler ()
virtual void handleReceivedData (const ConnectionBase *connection, const std::string &data)
virtual void handleConnect (const ConnectionBase *connection)
virtual void handleDisconnect (const ConnectionBase *connection, ConnectionError reason)
- Public Member Functions inherited from ConnectionDataHandler
virtual ~ConnectionDataHandler ()

Detailed Description

An implementation of a single SOCKS5 Bytestream (XEP-0065).

One instance of this class handles one bytestream.

See SOCKS5BytestreamManager for a detailed description on how to implement SOCKS5 Bytestreams in your application.

Jakob Schroeter

Definition at line 44 of file socks5bytestream.h.

Constructor & Destructor Documentation

~SOCKS5Bytestream ( )

Virtual destructor.

Definition at line 38 of file socks5bytestream.cpp.

Member Function Documentation

void close ( )

Closes the bytestream.

Definition at line 107 of file socks5bytestream.cpp.

bool connect ( )

This function starts the connection process. That is, it attempts to connect to each of the available StreamHosts. Once a working StreamHosts is found, the SOCKS5BytestreamManager is notified and the function returns.

True if a connection to a StreamHost could be established, false otherwise.
If false is returned you should hand this SOCKS5Bytestream object to SOCKS5BytestreamManager::dispose() for deletion.
Make sure you have a SOCKS5BytestreamDataHandler registered (using registerSOCKS5BytestreamDataHandler()) before calling this function.

Definition at line 61 of file socks5bytestream.cpp.

ConnectionBase* connectionImpl ( )

This function returns the concrete connection implementation currently in use.

The concrete connection implementation.

Definition at line 129 of file socks5bytestream.h.

void handleConnect ( const ConnectionBase connection)

This function is called when e.g. the raw TCP connection was established.

connectionThe connection.

Implements ConnectionDataHandler.

Definition at line 140 of file socks5bytestream.cpp.

void handleDisconnect ( const ConnectionBase connection,
ConnectionError  reason 

This connection is called when e.g. the raw TCP connection was closed.

connectionThe connection.
reasonThe reason for the disconnect.

Implements ConnectionDataHandler.

Definition at line 145 of file socks5bytestream.cpp.

void handleReceivedData ( const ConnectionBase connection,
const std::string &  data 

This function is called for received from the underlying transport.

connectionThe connection that received the data.
dataThe data received.

Implements ConnectionDataHandler.

Definition at line 117 of file socks5bytestream.cpp.

const JID& initiator ( ) const

Returns the initiating entity's JID. If this bytestream is remote-initiated, this is the remote entity's JID. If it is local-initiated, this is the local JID.

The initiator's JID.

Definition at line 115 of file socks5bytestream.h.

bool isOpen ( ) const

Returns whether the bytestream is open, that is, accepted by both parties.

Whether the bytestream is open or not.

Definition at line 58 of file socks5bytestream.h.

ConnectionError recv ( int  timeout = -1)

Call this function repeatedly to receive data from the socket. You should even do this if you use the bytestream to merely send data.

timeoutThe timeout to use for select in microseconds. Default of -1 means blocking.
The state of the connection.

Definition at line 92 of file socks5bytestream.cpp.

void registerSOCKS5BytestreamDataHandler ( SOCKS5BytestreamDataHandler s5bdh)

Use this function to register an object that will receive any notifications from the SOCKS5Bytestream instance. Only one SOCKS5BytestreamDataHandler can be registered at any one time.

s5bdhThe SOCKS5BytestreamDataHandler-derived object to receive notifications.

Definition at line 143 of file socks5bytestream.h.

void removeSOCKS5BytestreamDataHandler ( )

Removes the registered SOCKS5BytestreamDataHandler.

Definition at line 149 of file socks5bytestream.h.

bool send ( const std::string &  data)

Use this function to send a chunk of data over an open bytestream. There is no limit for the size of the chunk (other than your machine's memory). If the stream is not open or has been closed again (by the remote entity or locally), nothing is sent and false is returned.

dataThe block of data to send.
True if the data has been sent (no guarantee of receipt), false in case of an error.

Definition at line 84 of file socks5bytestream.cpp.

void setConnectionImpl ( ConnectionBase connection)

Sets the connection to use.

connectionThe connection. The bytestream will own the connection, any previously set connection gets deleted.

Definition at line 47 of file socks5bytestream.cpp.

void setStreamHosts ( const StreamHostList hosts)

Use this function to set the available StreamHosts. Usually you should not need to use this function directly.

Definition at line 135 of file socks5bytestream.h.

const std::string& sid ( ) const

Lets you retrieve the stream's ID.

The stream's ID.

Definition at line 101 of file socks5bytestream.h.

const JID& target ( ) const

Returns the target entity's JID. If this bytestream is remote-initiated, this is the local JID. If it is local-initiated, this is the remote entity's JID.

The target's JID.

Definition at line 108 of file socks5bytestream.h.

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