.TH "KNetwork::KBufferedSocket" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KNetwork::KBufferedSocket \- Buffered stream sockets.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kbufferedsocket.h>\fP
.PP
Inherits \fBKNetwork::KStreamSocket\fP.
.PP
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBbytesWritten\fP (int bytes)"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKBufferedSocket\fP (const \fBQString\fP &node=QString::null, const \fBQString\fP &service=QString::null, \fBQObject\fP *\fBparent\fP=0L, const char *\fBname\fP=0L)"
.br
.ti -1c
.RI "virtual \fB~KBufferedSocket\fP ()"
.br
.ti -1c
.RI "virtual void \fBsetSocketDevice\fP (\fBKSocketDevice\fP *device)"
.br
.ti -1c
.RI "virtual void \fBclose\fP ()"
.br
.ti -1c
.RI "virtual Q_LONG \fBbytesAvailable\fP () const "
.br
.ti -1c
.RI "virtual Q_LONG \fBwaitForMore\fP (int msecs, bool *timeout=0L)"
.br
.ti -1c
.RI "virtual Q_LONG \fBreadBlock\fP (char *data, Q_ULONG maxlen)"
.br
.ti -1c
.RI "virtual Q_LONG \fBreadBlock\fP (char *data, Q_ULONG maxlen, \fBKSocketAddress\fP &from)"
.br
.ti -1c
.RI "virtual Q_LONG \fBpeekBlock\fP (char *data, Q_ULONG maxlen)"
.br
.ti -1c
.RI "virtual Q_LONG \fBpeekBlock\fP (char *data, Q_ULONG maxlen, \fBKSocketAddress\fP &from)"
.br
.ti -1c
.RI "virtual Q_LONG \fBwriteBlock\fP (const char *data, Q_ULONG len)"
.br
.ti -1c
.RI "virtual Q_LONG \fBwriteBlock\fP (const char *data, Q_ULONG len, const \fBKSocketAddress\fP &to)"
.br
.ti -1c
.RI "virtual void \fBenableRead\fP (bool enable)"
.br
.ti -1c
.RI "virtual void \fBenableWrite\fP (bool enable)"
.br
.ti -1c
.RI "void \fBsetInputBuffering\fP (bool enable)"
.br
.ti -1c
.RI "\fBKIOBufferBase\fP * \fBinputBuffer\fP ()"
.br
.ti -1c
.RI "void \fBsetOutputBuffering\fP (bool enable)"
.br
.ti -1c
.RI "\fBKIOBufferBase\fP * \fBoutputBuffer\fP ()"
.br
.ti -1c
.RI "virtual Q_ULONG \fBbytesToWrite\fP () const "
.br
.ti -1c
.RI "virtual void \fBcloseNow\fP ()"
.br
.ti -1c
.RI "bool \fBcanReadLine\fP () const "
.br
.ti -1c
.RI "\fBQCString\fP \fBreadLine\fP ()"
.br
.ti -1c
.RI "void \fBreset\fP ()"
.br
.in -1c
.SS "Protected Slots"

.in +1c
.ti -1c
.RI "virtual void \fBslotReadActivity\fP ()"
.br
.ti -1c
.RI "virtual void \fBslotWriteActivity\fP ()"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBsetSocketOptions\fP (int opts)"
.br
.ti -1c
.RI "virtual void \fBstateChanging\fP (\fBSocketState\fP newState)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Buffered stream sockets. 

This class allows the user to create and operate buffered stream sockets such as those used in most Internet connections. This class is also the one that resembles the most to the old \fBQSocket\fP implementation.
.PP
Objects of this type operate only in non-blocking mode. A call to setBlocking(true) will result in an error.
.PP
\fBAuthor:\fP
.RS 4
Thiago Macieira <thiago.macieira@kdemail.net> 
.RE
.PP

.PP
Definition at line 52 of file kbufferedsocket.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KBufferedSocket::KBufferedSocket (const \fBQString\fP & node = \fCQString::null\fP, const \fBQString\fP & service = \fCQString::null\fP, \fBQObject\fP * parent = \fC0L\fP, const char * name = \fC0L\fP)"
.PP
Default constructor. 
.PP
\fBParameters:\fP
.RS 4
\fInode\fP destination host 
.br
\fIservice\fP destination service to connect to 
.br
\fIparent\fP the parent object for this object 
.br
\fIname\fP the internal name for this object 
.RE
.PP

.PP
Definition at line 50 of file kbufferedsocket.cpp.
.PP
References setInputBuffering(), and setOutputBuffering().
.SS "KBufferedSocket::~\fBKBufferedSocket\fP ()\fC [virtual]\fP"
.PP
Destructor. 
.PP
Definition at line 59 of file kbufferedsocket.cpp.
.PP
References closeNow().
.SH "Member Function Documentation"
.PP 
.SS "void KBufferedSocket::setSocketDevice (\fBKSocketDevice\fP * device)\fC [virtual]\fP"
.PP
Be sure to catch new devices. 
.PP
Reimplemented from \fBKNetwork::KSocketBase\fP.
.PP
Definition at line 67 of file kbufferedsocket.cpp.
.SS "bool KBufferedSocket::setSocketOptions (int opts)\fC [protected, virtual]\fP"
.PP
Buffered sockets can only operate in non-blocking mode. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 73 of file kbufferedsocket.cpp.
.SS "void KBufferedSocket::close ()\fC [virtual]\fP"
.PP
Closes the socket for new data, but allow data that had been buffered for output with \fBwriteBlock\fP to be still be written. 
.PP
\fBSee also:\fP
.RS 4
\fBcloseNow\fP 
.RE
.PP

.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 82 of file kbufferedsocket.cpp.
.PP
References closeNow(), KNetwork::KSocketDevice::readNotifier(), QSocketNotifier::setEnabled(), KNetwork::KClientSocketBase::setState(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KClientSocketBase::stateChanged().
.SS "Q_LONG KBufferedSocket::bytesAvailable () const\fC [virtual]\fP"
.PP
Make use of the buffers. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 96 of file kbufferedsocket.cpp.
.PP
Referenced by waitForMore().
.SS "Q_LONG KBufferedSocket::waitForMore (int msecs, bool * timeout = \fC0L\fP)\fC [virtual]\fP"
.PP
Make use of buffers. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 104 of file kbufferedsocket.cpp.
.PP
References bytesAvailable(), KNetwork::KActiveSocketBase::resetError(), and slotReadActivity().
.SS "Q_LONG KBufferedSocket::readBlock (char * data, Q_ULONG maxlen)\fC [virtual]\fP"
.PP
Reads data from the socket. 
.PP
Make use of buffers. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 116 of file kbufferedsocket.cpp.
.PP
References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), and KNetwork::KActiveSocketBase::setError().
.PP
Referenced by readBlock().
.SS "Q_LONG KBufferedSocket::readBlock (char * data, Q_ULONG maxlen, \fBKSocketAddress\fP & from)\fC [virtual]\fP"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Reads data from a socket.
.PP
The \fCfrom\fP parameter is always set to \fBpeerAddress()\fP 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 132 of file kbufferedsocket.cpp.
.PP
References KNetwork::KClientSocketBase::peerAddress(), and readBlock().
.SS "Q_LONG KBufferedSocket::peekBlock (char * data, Q_ULONG maxlen)\fC [virtual]\fP"
.PP
Peeks data from the socket. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 138 of file kbufferedsocket.cpp.
.PP
References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), and KNetwork::KActiveSocketBase::setError().
.PP
Referenced by peekBlock().
.SS "Q_LONG KBufferedSocket::peekBlock (char * data, Q_ULONG maxlen, \fBKSocketAddress\fP & from)\fC [virtual]\fP"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Peeks data from the socket.
.PP
The \fCfrom\fP parameter is always set to \fBpeerAddress()\fP 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 154 of file kbufferedsocket.cpp.
.PP
References peekBlock(), and KNetwork::KClientSocketBase::peerAddress().
.SS "Q_LONG KBufferedSocket::writeBlock (const char * data, Q_ULONG len)\fC [virtual]\fP"
.PP
Writes data to the socket. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 160 of file kbufferedsocket.cpp.
.PP
References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), QSocketNotifier::setEnabled(), KNetwork::KActiveSocketBase::setError(), KNetwork::KSocketBase::socketDevice(), KNetwork::KClientSocketBase::state(), and KNetwork::KSocketDevice::writeNotifier().
.PP
Referenced by writeBlock().
.SS "Q_LONG KBufferedSocket::writeBlock (const char * data, Q_ULONG len, const \fBKSocketAddress\fP & to)\fC [virtual]\fP"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Writes data to the socket.
.PP
The \fCto\fP parameter is discarded. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 190 of file kbufferedsocket.cpp.
.PP
References writeBlock().
.SS "void KBufferedSocket::enableRead (bool enable)\fC [virtual]\fP"
.PP
Catch changes. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 197 of file kbufferedsocket.cpp.
.PP
References KNetwork::KSocketDevice::readNotifier(), QSocketNotifier::setEnabled(), QTimer::singleShot(), slotReadActivity(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KClientSocketBase::state().
.PP
Referenced by stateChanging().
.SS "void KBufferedSocket::enableWrite (bool enable)\fC [virtual]\fP"
.PP
Catch changes. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 214 of file kbufferedsocket.cpp.
.PP
References QSocketNotifier::setEnabled(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KSocketDevice::writeNotifier().
.PP
Referenced by stateChanging().
.SS "void KBufferedSocket::setInputBuffering (bool enable)"
.PP
Sets the use of input buffering. 
.PP
Definition at line 244 of file kbufferedsocket.cpp.
.PP
References KNetwork::KSocketBase::mutex().
.PP
Referenced by KBufferedSocket().
.SS "\fBKIOBufferBase\fP * KBufferedSocket::inputBuffer ()"
.PP
Retrieves the input buffer object. 
.PP
Definition at line 258 of file kbufferedsocket.cpp.
.SS "void KBufferedSocket::setOutputBuffering (bool enable)"
.PP
Sets the use of output buffering. 
.PP
Definition at line 263 of file kbufferedsocket.cpp.
.PP
References KNetwork::KSocketBase::mutex().
.PP
Referenced by KBufferedSocket().
.SS "\fBKIOBufferBase\fP * KBufferedSocket::outputBuffer ()"
.PP
Retrieves the output buffer object. 
.PP
Definition at line 277 of file kbufferedsocket.cpp.
.SS "Q_ULONG KBufferedSocket::bytesToWrite () const\fC [virtual]\fP"
.PP
Returns the length of the output buffer. 
.PP
Definition at line 282 of file kbufferedsocket.cpp.
.SS "void KBufferedSocket::closeNow ()\fC [virtual]\fP"
.PP
Closes the socket and discards any output data that had been buffered with \fBwriteBlock\fP but that had not yet been written. 
.PP
\fBSee also:\fP
.RS 4
\fBclose\fP 
.RE
.PP

.PP
Definition at line 290 of file kbufferedsocket.cpp.
.PP
Referenced by close(), slotReadActivity(), slotWriteActivity(), and ~KBufferedSocket().
.SS "bool KBufferedSocket::canReadLine () const"
.PP
Returns true if a line can be read with \fBreadLine\fP. 
.PP
Definition at line 295 of file kbufferedsocket.cpp.
.SS "\fBQCString\fP KBufferedSocket::readLine ()"
.PP
Reads a line of data from the socket buffers. 
.PP
Definition at line 303 of file kbufferedsocket.cpp.
.SS "void KBufferedSocket::stateChanging (\fBSocketState\fP newState)\fC [protected, virtual]\fP"
.PP
Catch connection to clear the buffers. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 226 of file kbufferedsocket.cpp.
.PP
References KNetwork::KClientSocketBase::emitsReadyRead(), KNetwork::KClientSocketBase::emitsReadyWrite(), enableRead(), and enableWrite().
.SS "void KBufferedSocket::slotReadActivity ()\fC [protected, virtual, slot]\fP"
.PP
Slot called when there's read activity. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 308 of file kbufferedsocket.cpp.
.PP
References closeNow(), KNetwork::KClientSocketBase::copyError(), KNetwork::KClientSocketBase::emitsReadyRead(), KNetwork::KSocketBase::error(), KNetwork::KClientSocketBase::gotError(), QMutex::lock(), KNetwork::KSocketBase::mutex(), KNetwork::KClientSocketBase::readyRead(), KNetwork::KActiveSocketBase::setError(), QTimer::singleShot(), KNetwork::KSocketBase::socketDevice(), KNetwork::KClientSocketBase::state(), and QMutex::unlock().
.PP
Referenced by enableRead(), and waitForMore().
.SS "void KBufferedSocket::slotWriteActivity ()\fC [protected, virtual, slot]\fP"
.PP
Slot called when there's write activity. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 355 of file kbufferedsocket.cpp.
.PP
References bytesWritten(), closeNow(), KNetwork::KClientSocketBase::copyError(), KNetwork::KSocketBase::error(), KNetwork::KClientSocketBase::gotError(), QMutex::lock(), KNetwork::KSocketBase::mutex(), QSocketNotifier::setEnabled(), KNetwork::KActiveSocketBase::setError(), KNetwork::KSocketBase::socketDevice(), KNetwork::KClientSocketBase::state(), QMutex::unlock(), and KNetwork::KSocketDevice::writeNotifier().
.SS "void KNetwork::KBufferedSocket::bytesWritten (int bytes)\fC [signal]\fP"
.PP
This signal is emitted whenever data is written. 
.PP
Referenced by slotWriteActivity().
.SS "void KNetwork::KBufferedSocket::reset ()\fC [inline]\fP"
.PP
\fBDeprecated\fP
.RS 4
Closes the socket. 
.RE
.PP
This function is provided to ease porting from KExtendedSocket, which required a call to \fBreset()\fP in order to be able to connect again using the same device. This is not necessary in \fBKBufferedSocket\fP any more. 
.PP
Reimplemented from \fBQIODevice\fP.
.PP
Definition at line 233 of file kbufferedsocket.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
