ControlSocket Class Reference

#include <controlsocket.h>

List of all members.

Public Member Functions

 ControlSocket ()
bool connect (QHostAddress addr, quint16 port, QString *errmsg=0)
bool disconnect (QString *errmsg=0)
bool sendCommand (ControlCommand cmd, QString *errmsg=0)
bool readReply (ControlReply &reply, QString *errmsg=0)
bool isConnected ()

Protected Member Functions

bool readLineData (QString &line, QString *errmsg=0)
bool readLine (QString &line, QString *errmsg=0)


Detailed Description

Definition at line 38 of file controlsocket.h.


Constructor & Destructor Documentation

ControlSocket::ControlSocket (  ) 

Default constructor and destructor

Default constructor.

Definition at line 45 of file controlsocket.cpp.


Member Function Documentation

bool ControlSocket::connect ( QHostAddress  addr,
quint16  port,
QString *  errmsg = 0 
)

Connect to Tor on the specified host and port

Connects to Tor's control socket on the specified host and port. If the connection is successful, true is returned. If the connection fails, then this function returns false and sets errmsg appropriately, if not null.

Definition at line 54 of file controlsocket.cpp.

References CONN_TIMEOUT, err(), vNotice, and vWarn.

Referenced by ControlConnection::connect().

bool ControlSocket::disconnect ( QString *  errmsg = 0  ) 

Disconnect from Tor

Disconnects from Tor's control socket

Definition at line 72 of file controlsocket.cpp.

References CONN_TIMEOUT, err(), isConnected(), and vWarn.

bool ControlSocket::sendCommand ( ControlCommand  cmd,
QString *  errmsg = 0 
)

Send a command to Tor

Send a control command to Tor on the control socket, conforming to Tor's Control Protocol V1:

Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data Keyword = 1*ALPHA Arguments = *(SP / VCHAR)

Definition at line 101 of file controlsocket.cpp.

References err(), isConnected(), ControlCommand::toString(), and vInfo.

Referenced by ControlConnection::eventFilter(), and ControlConnection::send().

bool ControlSocket::readReply ( ControlReply reply,
QString *  errmsg = 0 
)

Read a response from Tor

Read a complete reply from the control socket. Replies take the following form, based on Tor's Control Protocol v1:

Reply = *(MidReplyLine / DataReplyLine) EndReplyLine

MidReplyLine = "-" ReplyLine DataReplyLine = "+" ReplyLine Data EndReplyLine = SP ReplyLine ReplyLine = StatusCode [ SP ReplyText ] CRLF ReplyText = XXXX StatusCode = XXiX

Definition at line 172 of file controlsocket.cpp.

References ControlReply::appendLine(), err(), isConnected(), and readLine().

Referenced by ControlConnection::onReadyRead().

bool ControlSocket::isConnected (  ) 

Returns true if the control socket is connected and ready to send or receive.

Definition at line 88 of file controlsocket.cpp.

Referenced by disconnect(), readLine(), readReply(), and sendCommand().

bool ControlSocket::readLineData ( QString &  line,
QString *  errmsg = 0 
) [protected]

Reads line data off the socket in chunks.

Reads line data, one chunk at a time, until a newline character is encountered.

Definition at line 123 of file controlsocket.cpp.

References err().

Referenced by readLine().

bool ControlSocket::readLine ( QString &  line,
QString *  errmsg = 0 
) [protected]

Reads a line of data from the socket (blocking)

Reads a line of data from the socket and returns true if successful or false if an error occurred while waiting for a line of data to become available.

Definition at line 144 of file controlsocket.cpp.

References err(), isConnected(), READ_TIMEOUT, and readLineData().

Referenced by readReply().


The documentation for this class was generated from the following files:
Generated on Wed Sep 5 15:49:29 2007 for Vidalia by  doxygen 1.5.3