KDECore
KSocket Class Reference
A TCP/IP client socket. More...
#include <ksock.h>
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.
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.
Definition at line 87 of file ksock.h.
Constructor & Destructor Documentation
KSocket::KSocket | ( | int | _sock | ) |
KSocket::KSocket | ( | const char * | _host, | |
unsigned short int | _port, | |||
int | timeOut = 30 | |||
) |
KSocket::KSocket | ( | const char * | _path | ) |
KSocket::~KSocket | ( | ) | [virtual] |
Member Function Documentation
void KSocket::closeEvent | ( | KSocket * | s | ) | [signal] |
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
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
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] |
void KSocket::slotWrite | ( | int | x | ) | [slot] |
int KSocket::socket | ( | ) | const [inline] |
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] |
The documentation for this class was generated from the following files: