• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • KNetwork
  • TDEBufferedSocket
Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
KNetwork::TDEBufferedSocket Class Reference

#include <kbufferedsocket.h>

Inheritance diagram for KNetwork::TDEBufferedSocket:
KNetwork::KStreamSocket KNetwork::KClientSocketBase KNetwork::KActiveSocketBase KNetwork::TDESocketBase

Signals

void bytesWritten (int bytes)
 
- Signals inherited from KNetwork::KStreamSocket
void timedOut ()
 
- Signals inherited from KNetwork::KClientSocketBase
void stateChanged (int newstate)
 
void gotError (int code)
 
void hostFound ()
 
void bound (const KResolverEntry &local)
 
void aboutToConnect (const KResolverEntry &remote, bool &skip)
 
void connected (const KResolverEntry &remote)
 
void closed ()
 
void readyRead ()
 
void readyWrite ()
 

Public Member Functions

 TDEBufferedSocket (const TQString &node=TQString::null, const TQString &service=TQString::null, TQObject *parent=0L, const char *name=0L)
 
virtual ~TDEBufferedSocket ()
 
virtual void setSocketDevice (TDESocketDevice *device)
 
virtual void close ()
 
virtual TQ_LONG bytesAvailable () const
 
virtual TQ_LONG waitForMore (int msecs, bool *timeout=0L)
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG maxlen)
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen)
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len)
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len, const TDESocketAddress &to)
 
virtual void enableRead (bool enable)
 
virtual void enableWrite (bool enable)
 
void setInputBuffering (bool enable)
 
TDEIOBufferBase * inputBuffer ()
 
void setOutputBuffering (bool enable)
 
TDEIOBufferBase * outputBuffer ()
 
virtual TQ_ULONG bytesToWrite () const
 
virtual void closeNow ()
 
bool canReadLine () const
 
TQCString readLine ()
 
void waitForConnect ()
 
void reset ()
 
- Public Member Functions inherited from KNetwork::KStreamSocket
 KStreamSocket (const TQString &node=TQString::null, const TQString &service=TQString::null, TQObject *parent=0L, const char *name=0L)
 
virtual ~KStreamSocket ()
 
int timeout () const
 
int remainingTimeout () const
 
void setTimeout (int msecs)
 
virtual bool bind (const TQString &node=TQString::null, const TQString &service=TQString::null)
 
virtual bool bind (const KResolverEntry &entry)
 
virtual bool connect (const TQString &node=TQString::null, const TQString &service=TQString::null)
 
virtual bool connect (const KResolverEntry &entry)
 
- Public Member Functions inherited from KNetwork::KClientSocketBase
 KClientSocketBase (TQObject *parent, const char *name)
 
virtual ~KClientSocketBase ()
 
SocketState state () const
 
KResolver & peerResolver () const
 
const KResolverResults & peerResults () const
 
KResolver & localResolver () const
 
const KResolverResults & localResults () const
 
void setResolutionEnabled (bool enable)
 
void setFamily (int families)
 
virtual bool lookup ()
 
virtual bool bind (const TQString &node=TQString::null, const TQString &service=TQString::null)=0
 
virtual bool bind (const KResolverEntry &address)
 
virtual bool connect (const TQString &node=TQString::null, const TQString &service=TQString::null)=0
 
virtual bool connect (const KResolverEntry &address)
 
void connectToHost (const TQString &host, TQ_UINT16 port)
 
virtual bool disconnect ()
 
virtual bool open (int)
 
virtual void close ()
 
virtual void flush ()
 
virtual TQ_LONG bytesAvailable () const
 
virtual TQ_LONG waitForMore (int msecs, bool *timeout=0L)
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG maxlen)
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen)
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len)
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len, const TDESocketAddress &to)
 
virtual TDESocketAddress localAddress () const
 
virtual TDESocketAddress peerAddress () const
 
bool emitsReadyRead () const
 
virtual void enableRead (bool enable)
 
bool emitsReadyWrite () const
 
virtual void enableWrite (bool enable)
 
- Public Member Functions inherited from KNetwork::KActiveSocketBase
 KActiveSocketBase ()
 
virtual ~KActiveSocketBase ()
 
virtual bool bind (const KResolverEntry &address)=0
 
virtual bool connect (const KResolverEntry &address)=0
 
virtual bool disconnect ()=0
 
virtual Offset size () const
 
virtual Offset at () const
 
virtual bool at (Offset)
 
virtual bool atEnd () const
 
virtual TQ_LONG bytesAvailable () const =0
 
virtual TQ_LONG waitForMore (int msecs, bool *timeout=0L)=0
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG len)=0
 
virtual TQ_LONG readBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)=0
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen)=0
 
virtual TQ_LONG peekBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from)=0
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len)=0
 
virtual TQ_LONG writeBlock (const char *data, TQ_ULONG len, const TDESocketAddress &to)=0
 
virtual int getch ()
 
virtual int putch (int ch)
 
virtual int ungetch (int)
 
virtual TDESocketAddress localAddress () const =0
 
virtual TDESocketAddress peerAddress () const =0
 
- Public Member Functions inherited from KNetwork::TDESocketBase
 TDESocketBase ()
 
virtual ~TDESocketBase ()
 
virtual bool setBlocking (bool enable)
 
bool blocking () const
 
virtual bool setAddressReuseable (bool enable)
 
bool addressReuseable () const
 
virtual bool setIPv6Only (bool enable)
 
bool isIPv6Only () const
 
virtual bool setBroadcast (bool enable)
 
bool broadcast () const
 
TDESocketDevice * socketDevice () const
 
virtual void setSocketDevice (TDESocketDevice *device)
 
int setRequestedCapabilities (int add, int remove=0)
 
SocketError error () const
 
TQString errorString () const
 
TQMutex * mutex () const
 

Protected Slots

virtual void slotReadActivity ()
 
virtual void slotWriteActivity ()
 
- Protected Slots inherited from KNetwork::KClientSocketBase
virtual void slotReadActivity ()
 
virtual void slotWriteActivity ()
 

Protected Member Functions

virtual bool setSocketOptions (int opts)
 
virtual void stateChanging (SocketState newState)
 
- Protected Member Functions inherited from KNetwork::KClientSocketBase
virtual bool setSocketOptions (int opts)
 
void setState (SocketState state)
 
virtual void stateChanging (SocketState newState)
 
void copyError ()
 
- Protected Member Functions inherited from KNetwork::KActiveSocketBase
void setError (int status, SocketError error)
 
void resetError ()
 
- Protected Member Functions inherited from KNetwork::TDESocketBase
virtual bool setSocketOptions (int opts)
 
virtual int socketOptions () const
 
bool hasDevice () const
 
void setError (SocketError error)
 

Additional Inherited Members

- Public Types inherited from KNetwork::KClientSocketBase
enum  SocketState {
  Idle , HostLookup , HostFound , Bound ,
  Connecting , Open , Closing , Unconnected = Bound ,
  Connected = Open , Connection = Open
}
 
- Public Types inherited from KNetwork::TDESocketBase
enum  SocketOptions {
  Blocking = 0x01 , AddressReuseable = 0x02 , IPv6Only = 0x04 , Keepalive = 0x08 ,
  Broadcast = 0x10
}
 
enum  SocketError {
  NoError = 0 , LookupFailure , AddressInUse , AlreadyCreated ,
  AlreadyBound , AlreadyConnected , NotConnected , NotBound ,
  NotCreated , WouldBlock , ConnectionRefused , ConnectionTimedOut ,
  InProgress , NetFailure , NotSupported , Timeout ,
  UnknownError , RemotelyDisconnected
}
 
- Static Public Member Functions inherited from KNetwork::TDESocketBase
static TQString errorString (SocketError code)
 
static bool isFatalError (int code)
 

Detailed Description

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 QSocket implementation.

Objects of this type operate only in non-blocking mode. A call to setBlocking(true) will result in an error.

Note
Buffered sockets only make sense if you're using them from the main (event-loop) thread. This is actually a restriction imposed by Qt's TQSocketNotifier. If you want to use a socket in an auxiliary thread, please use KStreamSocket.
See also
KNetwork::KStreamSocket, KNetwork::TDEServerSocket
Author
Thiago Macieira thiag.nosp@m.o@kd.nosp@m.e.org

Definition at line 58 of file kbufferedsocket.h.

Constructor & Destructor Documentation

◆ TDEBufferedSocket()

TDEBufferedSocket::TDEBufferedSocket ( const TQString &  node = TQString::null,
const TQString &  service = TQString::null,
TQObject *  parent = 0L,
const char *  name = 0L 
)

Default constructor.

Parameters
nodedestination host
servicedestination service to connect to
parentthe parent object for this object
namethe internal name for this object

Definition at line 50 of file kbufferedsocket.cpp.

◆ ~TDEBufferedSocket()

TDEBufferedSocket::~TDEBufferedSocket ( )
virtual

Destructor.

Definition at line 59 of file kbufferedsocket.cpp.

Member Function Documentation

◆ bytesAvailable()

TQ_LONG TDEBufferedSocket::bytesAvailable ( ) const
virtual

Make use of the buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 96 of file kbufferedsocket.cpp.

◆ bytesToWrite()

TQ_ULONG TDEBufferedSocket::bytesToWrite ( ) const
virtual

Returns the length of the output buffer.

Definition at line 282 of file kbufferedsocket.cpp.

◆ bytesWritten

void KNetwork::TDEBufferedSocket::bytesWritten ( int  bytes)
signal

This signal is emitted whenever data is written.

◆ canReadLine()

bool TDEBufferedSocket::canReadLine ( ) const

Returns true if a line can be read with readLine.

Definition at line 297 of file kbufferedsocket.cpp.

◆ close()

void TDEBufferedSocket::close ( )
virtual

Closes the socket for new data, but allow data that had been buffered for output with writeBlock to be still be written.

See also
closeNow

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 82 of file kbufferedsocket.cpp.

◆ closeNow()

void TDEBufferedSocket::closeNow ( )
virtual

Closes the socket and discards any output data that had been buffered with writeBlock but that had not yet been written.

See also
close

Definition at line 290 of file kbufferedsocket.cpp.

◆ enableRead()

void TDEBufferedSocket::enableRead ( bool  enable)
virtual

Catch changes.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 197 of file kbufferedsocket.cpp.

◆ enableWrite()

void TDEBufferedSocket::enableWrite ( bool  enable)
virtual

Catch changes.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 214 of file kbufferedsocket.cpp.

◆ inputBuffer()

TDEIOBufferBase * TDEBufferedSocket::inputBuffer ( )

Retrieves the input buffer object.

Definition at line 258 of file kbufferedsocket.cpp.

◆ outputBuffer()

TDEIOBufferBase * TDEBufferedSocket::outputBuffer ( )

Retrieves the output buffer object.

Definition at line 277 of file kbufferedsocket.cpp.

◆ peekBlock() [1/2]

TQ_LONG TDEBufferedSocket::peekBlock ( char *  data,
TQ_ULONG  maxlen 
)
virtual

Peeks data from the socket.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 138 of file kbufferedsocket.cpp.

◆ peekBlock() [2/2]

TQ_LONG TDEBufferedSocket::peekBlock ( char *  data,
TQ_ULONG  maxlen,
TDESocketAddress &  from 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Peeks data from the socket.

The from parameter is always set to peerAddress()

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 154 of file kbufferedsocket.cpp.

◆ readBlock() [1/2]

TQ_LONG TDEBufferedSocket::readBlock ( char *  data,
TQ_ULONG  maxlen 
)
virtual

Reads data from the socket.

Make use of buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 116 of file kbufferedsocket.cpp.

◆ readBlock() [2/2]

TQ_LONG TDEBufferedSocket::readBlock ( char *  data,
TQ_ULONG  maxlen,
TDESocketAddress &  from 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Reads data from a socket.

The from parameter is always set to peerAddress()

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 132 of file kbufferedsocket.cpp.

◆ readLine()

TQCString TDEBufferedSocket::readLine ( )

Reads a line of data from the socket buffers.

Definition at line 305 of file kbufferedsocket.cpp.

◆ reset()

void KNetwork::TDEBufferedSocket::reset ( )
inline
Deprecated:
Closes the socket.

This function is provided to ease porting from KExtendedSocket, which required a call to reset() in order to be able to connect again using the same device. This is not necessary in TDEBufferedSocket any more.

Definition at line 246 of file kbufferedsocket.h.

◆ setInputBuffering()

void TDEBufferedSocket::setInputBuffering ( bool  enable)

Sets the use of input buffering.

Definition at line 244 of file kbufferedsocket.cpp.

◆ setOutputBuffering()

void TDEBufferedSocket::setOutputBuffering ( bool  enable)

Sets the use of output buffering.

Definition at line 263 of file kbufferedsocket.cpp.

◆ setSocketDevice()

void TDEBufferedSocket::setSocketDevice ( TDESocketDevice *  device)
virtual

Be sure to catch new devices.

Reimplemented from KNetwork::TDESocketBase.

Definition at line 67 of file kbufferedsocket.cpp.

◆ setSocketOptions()

bool TDEBufferedSocket::setSocketOptions ( int  opts)
protectedvirtual

Buffered sockets can only operate in non-blocking mode.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 73 of file kbufferedsocket.cpp.

◆ slotReadActivity

void TDEBufferedSocket::slotReadActivity ( )
protectedvirtualslot

Slot called when there's read activity.

Definition at line 320 of file kbufferedsocket.cpp.

◆ slotWriteActivity

void TDEBufferedSocket::slotWriteActivity ( )
protectedvirtualslot

Slot called when there's write activity.

Definition at line 367 of file kbufferedsocket.cpp.

◆ stateChanging()

void TDEBufferedSocket::stateChanging ( SocketState  newState)
protectedvirtual

Catch connection to clear the buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 226 of file kbufferedsocket.cpp.

◆ waitForConnect()

void TDEBufferedSocket::waitForConnect ( )

Blocks until the connection is either established, or completely failed.

Definition at line 310 of file kbufferedsocket.cpp.

◆ waitForMore()

TQ_LONG TDEBufferedSocket::waitForMore ( int  msecs,
bool *  timeout = 0L 
)
virtual

Make use of buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 104 of file kbufferedsocket.cpp.

◆ writeBlock() [1/2]

TQ_LONG TDEBufferedSocket::writeBlock ( const char *  data,
TQ_ULONG  len 
)
virtual

Writes data to the socket.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 160 of file kbufferedsocket.cpp.

◆ writeBlock() [2/2]

TQ_LONG TDEBufferedSocket::writeBlock ( const char *  data,
TQ_ULONG  len,
const TDESocketAddress &  to 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes data to the socket.

The to parameter is discarded.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 190 of file kbufferedsocket.cpp.


The documentation for this class was generated from the following files:
  • kbufferedsocket.h
  • kbufferedsocket.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.