• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDECore

KSocket Class Reference

A TCP/IP client socket. More...

#include <ksock.h>

Inheritance diagram for KSocket:

Inheritance graph
[legend]

List of all members.


Public Slots

void slotRead (int x)
void slotWrite (int x)

Signals

void closeEvent (KSocket *s)
void readEvent (KSocket *s)
void writeEvent (KSocket *s)

Public Member Functions

void enableRead (bool enable)
void enableWrite (bool enable)
 KSocket (const char *_path) KDE_DEPRECATED
 KSocket (const char *_host, unsigned short int _port, int timeOut=30) KDE_DEPRECATED
 KSocket (int _sock) KDE_DEPRECATED
int socket () const
virtual ~KSocket ()

Protected Member Functions

bool connect (const char *_path)
bool connect (const QString &_host, unsigned short int _port, int timeout=0)

Protected Attributes

int sock

Detailed Description

A TCP/IP client socket.

Deprecated:
You can connect this socket to any Internet address.
This class is deprecated and will be removed in the future. For new programs, please use KExtendedSocket class.

The socket gives you three signals: When ready for reading, ready for writing or if the connection is broken. Using socket() you get a file descriptor which you can use with the usual UNIX function like write() or read(). If you have already such a socket identifier you can construct a KSocket on this identifier.

If socket() delivers a value of -1 or less, the connection was not successful.

Author:
Torben Weis <weis@uni-frankfurt.de>

Definition at line 87 of file ksock.h.


Constructor & Destructor Documentation

KSocket::KSocket ( int  _sock  ) 

Constructs a KSocket with the provided file descriptor.

Parameters:
_sock The file descriptor to use.

Definition at line 105 of file ksock.cpp.

KSocket::KSocket ( const char *  _host,
unsigned short int  _port,
int  timeOut = 30 
)

Creates a socket and connects to a host.

Parameters:
_host The remote host to which to connect.
_port The port on the remote host.
timeOut The number of seconds waiting for connect (default 30).

Definition at line 119 of file ksock.cpp.

KSocket::KSocket ( const char *  _path  ) 

Connects to a UNIX domain socket.

Parameters:
_path The filename of the socket.

Definition at line 125 of file ksock.cpp.

KSocket::~KSocket (  )  [virtual]

Destructor.

Closes the socket if it is still open.

Definition at line 264 of file ksock.cpp.


Member Function Documentation

void KSocket::closeEvent ( KSocket *  s  )  [signal]

Raised when the connection is broken.

Parameters:
s the KSocket that triggered the event

bool KSocket::connect ( const char *  _path  )  [protected]

Definition at line 183 of file ksock.cpp.

bool KSocket::connect ( const QString &  _host,
unsigned short int  _port,
int  timeout = 0 
) [protected]

Definition at line 197 of file ksock.cpp.

void KSocket::enableRead ( bool  enable  ) 

Enables the socket for reading.

If you enable read mode, the socket will emit the signal readEvent() whenever there is something to read out of this socket.

Parameters:
enable true to enable reading signals

Definition at line 131 of file ksock.cpp.

void KSocket::enableWrite ( bool  enable  ) 

Enables the socket for writing.

If you enable write mode, the socket will emit the signal writeEvent() whenever the socket is ready for writing.

Warning: If you forget to call enableWrite(false) when you are not ready to send data, you will get lots of writeEvent() signals, in the order of thousands a second !

Parameters:
enable true to enable writing signals

Definition at line 147 of file ksock.cpp.

void KSocket::readEvent ( KSocket *  s  )  [signal]

Data has arrived for reading.

This signal will only be raised if enableRead( true ) was called first.

Parameters:
s the KSocket that triggered the event

void KSocket::slotRead ( int  x  )  [slot]

Connected to the readNotifier.

Called when the socket is ready for reading.

Parameters:
x ignored

Definition at line 164 of file ksock.cpp.

void KSocket::slotWrite ( int  x  )  [slot]

Connected to the writeNotifier.

Called when the socket is ready for writing.

Parameters:
x ignored

Definition at line 175 of file ksock.cpp.

int KSocket::socket (  )  const [inline]

Returns a file descriptor for this socket.

Returns:
the file descriptor, or -1 when an error occurred.

Definition at line 119 of file ksock.h.

void KSocket::writeEvent ( KSocket *  s  )  [signal]

Socket is ready for writing.

This signal will only be raised if enableWrite( true ) was called first.

Warning: If you forget to call enableWrite(false) when you are not ready to send data, you will get lots of writeEvent() signals, in the order of thousands a second !

Parameters:
s the KSocket that triggered the event


Member Data Documentation

int KSocket::sock [protected]

Definition at line 220 of file ksock.h.


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

KDECore

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal