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

tdecore

  • KNetwork
  • KActiveSocketBase
Public Member Functions | Protected Member Functions | List of all members
KNetwork::KActiveSocketBase Class Referenceabstract

#include <tdesocketbase.h>

Inheritance diagram for KNetwork::KActiveSocketBase:
KNetwork::TDESocketBase KNetwork::KClientSocketBase KNetwork::TDESocketDevice KNetwork::KDatagramSocket KNetwork::KStreamSocket KNetwork::KHttpProxySocketDevice KNetwork::KMulticastSocketImpl KNetwork::KSocksSocketDevice KNetwork::KMulticastSocket KNetwork::TDEBufferedSocket

Public Member Functions

 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 Member Functions

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::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

Abstract class for active sockets.

This class provides the standard interfaces for active sockets, i.e., sockets that are used to connect to external addresses.

Author
Thiago Macieira thiag.nosp@m.o.ma.nosp@m.cieir.nosp@m.a@kd.nosp@m.email.nosp@m..net

Definition at line 443 of file tdesocketbase.h.

Constructor & Destructor Documentation

◆ KActiveSocketBase()

KActiveSocketBase::KActiveSocketBase ( )

Constructor.

Definition at line 283 of file tdesocketbase.cpp.

◆ ~KActiveSocketBase()

KActiveSocketBase::~KActiveSocketBase ( )
virtual

Destructor.

Definition at line 287 of file tdesocketbase.cpp.

Member Function Documentation

◆ at() [1/2]

virtual Offset KNetwork::KActiveSocketBase::at ( ) const
inlinevirtual

This call is not supported on sockets.

Reimplemented from TQIODevice. This will always return 0.

Definition at line 514 of file tdesocketbase.h.

◆ at() [2/2]

virtual bool KNetwork::KActiveSocketBase::at ( Offset  )
inlinevirtual

This call is not supported on sockets.

Reimplemented from TQIODevice. This will always return false.

Definition at line 521 of file tdesocketbase.h.

◆ atEnd()

virtual bool KNetwork::KActiveSocketBase::atEnd ( ) const
inlinevirtual

This call is not supported on sockets.

Reimplemented from TQIODevice. This will always return true.

Definition at line 528 of file tdesocketbase.h.

◆ bind()

virtual bool KNetwork::KActiveSocketBase::bind ( const KResolverEntry &  address)
pure virtual

Binds this socket to the given address.

The socket will be constructed with the address family, socket type and protocol as those given in the address object.

Parameters
addressthe address to bind to
Returns
true if the binding was successful, false otherwise

Implemented in KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, KNetwork::TDESocketDevice, KNetwork::KDatagramSocket, and KNetwork::KStreamSocket.

◆ bytesAvailable()

virtual TQ_LONG KNetwork::KActiveSocketBase::bytesAvailable ( ) const
pure virtual

Returns the number of bytes available for reading without blocking.

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, and KNetwork::TDESocketDevice.

◆ connect()

virtual bool KNetwork::KActiveSocketBase::connect ( const KResolverEntry &  address)
pure virtual

Connect to a remote host.

This will make this socket try to connect to the remote host. If the socket is not yet created, it will be created using the address family, socket type and protocol specified in the address object.

If this function returns with error InProgress, calling it again with the same address after a time will cause it to test if the connection has succeeded in the mean time.

Parameters
addressthe address to connect to
Returns
true if the connection was successful or has been successfully queued; false if an error occurred.

Implemented in KNetwork::KClientSocketBase, KNetwork::KHttpProxySocketDevice, KNetwork::KSocksSocketDevice, KNetwork::KMulticastSocketImpl, KNetwork::TDESocketDevice, KNetwork::KDatagramSocket, and KNetwork::KStreamSocket.

◆ disconnect()

virtual bool KNetwork::KActiveSocketBase::disconnect ( )
pure virtual

Disconnects this socket from a connection, if possible.

If this socket was connected to an endpoint, the connection is severed, but the socket is not closed. If the socket wasn't connected, this function does nothing.

If the socket hadn't yet been created, this function does nothing either.

Not all socket types can disconnect. Most notably, only connectionless datagram protocols such as UDP support this operation.

Returns
true if the socket is now disconnected or false on error.

Implemented in KNetwork::KClientSocketBase, and KNetwork::TDESocketDevice.

◆ getch()

int KActiveSocketBase::getch ( )
virtual

Reads one character from the socket.

Reimplementation from TQIODevice. See TQIODevice::getch for more information.

Definition at line 291 of file tdesocketbase.cpp.

◆ localAddress()

virtual TDESocketAddress KNetwork::KActiveSocketBase::localAddress ( ) const
pure virtual

Returns this socket's local address.

Implemented in KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ peekBlock() [1/2]

virtual TQ_LONG KNetwork::KActiveSocketBase::peekBlock ( char *  data,
TQ_ULONG  maxlen 
)
pure virtual

Peeks the data in the socket.

This call will allow you to peek the data to be received without actually receiving it – that is, it will be available for further peekings and for the next read call.

Parameters
datawhere to write the peeked data to
maxlenthe maximum number of bytes to peek
Returns
the actual number of bytes copied into data

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ peekBlock() [2/2]

virtual TQ_LONG KNetwork::KActiveSocketBase::peekBlock ( char *  data,
TQ_ULONG  maxlen,
TDESocketAddress &  from 
)
pure virtual

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

This call will allow you to peek the data to be received without actually receiving it – that is, it will be available for further peekings and for the next read call.

Parameters
datawhere to write the peeked data to
maxlenthe maximum number of bytes to peek
fromthe address of the sender will be stored here
Returns
the actual number of bytes copied into data

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ peerAddress()

virtual TDESocketAddress KNetwork::KActiveSocketBase::peerAddress ( ) const
pure virtual

Return this socket's peer address, if we are connected.

If the address cannot be retrieved, the returned object will contain an invalid address.

Implemented in KNetwork::KClientSocketBase, KNetwork::KHttpProxySocketDevice, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ putch()

int KActiveSocketBase::putch ( int  ch)
virtual

Writes one character to the socket.

Reimplementation from TQIODevice. See TQIODevice::putch for more information.

Definition at line 300 of file tdesocketbase.cpp.

◆ readBlock() [1/2]

virtual TQ_LONG KNetwork::KActiveSocketBase::readBlock ( char *  data,
TQ_ULONG  len 
)
pure virtual

Reads data from the socket.

Reimplemented from TQIODevice. See TQIODevice::readBlock for more information.

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ readBlock() [2/2]

virtual TQ_LONG KNetwork::KActiveSocketBase::readBlock ( char *  data,
TQ_ULONG  maxlen,
TDESocketAddress &  from 
)
pure virtual

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

This call will read data in the socket and will also place the sender's address in from object.

Parameters
datawhere to write the read data to
maxlenthe maximum number of bytes to read
fromthe address of the sender will be stored here
Returns
the actual number of bytes read

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ resetError()

void KActiveSocketBase::resetError ( )
protected

Resets the socket error code and the I/O Device's status.

Definition at line 315 of file tdesocketbase.cpp.

◆ setError()

void KActiveSocketBase::setError ( int  status,
SocketError  error 
)
protected

Sets the socket's error code and the I/O Device's status.

Parameters
statusthe I/O Device status
errorthe error code

Definition at line 309 of file tdesocketbase.cpp.

◆ size()

virtual Offset KNetwork::KActiveSocketBase::size ( ) const
inlinevirtual

This call is not supported on sockets.

Reimplemented from TQIODevice. This will always return 0.

Definition at line 507 of file tdesocketbase.h.

◆ ungetch()

virtual int KNetwork::KActiveSocketBase::ungetch ( int  )
inlinevirtual

This call is not supported on sockets.

Reimplemented from TQIODevice. This will always return -1;

Definition at line 635 of file tdesocketbase.h.

◆ waitForMore()

virtual TQ_LONG KNetwork::KActiveSocketBase::waitForMore ( int  msecs,
bool *  timeout = 0L 
)
pure virtual

Waits up to msecs for more data to be available on this socket.

If msecs is -1, this call will block indefinetely until more data is indeed available; if it's 0, this function returns immediately.

If timeout is not NULL, this function will set it to indicate if a timeout occurred.

Returns
the number of bytes available

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, and KNetwork::TDESocketDevice.

◆ writeBlock() [1/2]

virtual TQ_LONG KNetwork::KActiveSocketBase::writeBlock ( const char *  data,
TQ_ULONG  len 
)
pure virtual

Writes the given data to the socket.

Reimplemented from TQIODevice. See TQIODevice::writeBlock for more information.

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.

◆ writeBlock() [2/2]

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

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

Note that not all socket connections allow sending data to different addresses than the one the socket is connected to.

Parameters
datathe data to write
lenthe length of the data
tothe address to send to
Returns
the number of bytes actually sent

Implemented in KNetwork::TDEBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KDatagramSocket, KNetwork::KSocksSocketDevice, and KNetwork::TDESocketDevice.


The documentation for this class was generated from the following files:
  • tdesocketbase.h
  • tdesocketbase.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.