KSocket Class Reference
You can connect this socket to any Internet address. A TCP/IP client socket. More...
#include <ksock.h>
Inheritance diagram for KSocket:


Public Slots | |
void | slotWrite (int x) |
Connected to the writeNotifier. | |
void | slotRead (int x) |
Connected to the readNotifier. | |
Signals | |
void | readEvent (KSocket *s) |
Data has arrived for reading. | |
void | writeEvent (KSocket *s) |
Socket is ready for writing. | |
void | closeEvent (KSocket *s) |
Raised when the connection is broken. | |
Public Member Functions | |
KSocket (int _sock) | |
Constructs a KSocket with the provided file descriptor. | |
KSocket (const char *_host, unsigned short int _port, int timeOut=30) | |
Creates a socket and connects to a host. | |
KSocket (const char *_path) | |
Connects to a UNIX domain socket. | |
virtual | ~KSocket () |
Destructor. | |
int | socket () const |
Returns a file descriptor for this socket. | |
void | enableRead (bool enable) |
Enables the socket for reading. | |
void | enableWrite (bool enable) |
Enables the socket for writing. | |
Protected Member Functions | |
bool | connect (const QString &_host, unsigned short int _port, int timeout=0) |
bool | connect (const char *_path) |
Protected Attributes | |
int | sock |
Detailed Description
You can connect this socket to any Internet address. A TCP/IP client socket.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>
- Version:
- Id
- ksock.h,v 1.53 2002/09/09 21:24:53 tjansen Exp
Definition at line 81 of file ksock.h.
Constructor & Destructor Documentation
|
Constructs a KSocket with the provided file descriptor.
Definition at line 101 of file ksock.cpp. References KSocks::getsockname(), and KSocks::self(). |
|
Creates a socket and connects to a host.
Definition at line 115 of file ksock.cpp. References QObject::connect(). |
|
Connects to a UNIX domain socket.
Definition at line 121 of file ksock.cpp. References QObject::connect(). |
|
Destructor. Closes the socket if it is still open. |
Member Function Documentation
|
Returns a file descriptor for this socket.
|
|
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.
Definition at line 127 of file ksock.cpp. References QObject::connect(), and slotRead(). |
|
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 !
Definition at line 143 of file ksock.cpp. References QObject::connect(), and slotWrite(). |
|
Data has arrived for reading.
This signal will only be raised if enableRead(
Referenced by slotRead(). |
|
Socket is ready for writing.
This signal will only be raised if enableWrite( 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 !
Referenced by slotWrite(). |
|
Raised when the connection is broken.
Referenced by slotRead(). |
|
Connected to the writeNotifier. Called when the socket is ready for writing.
Definition at line 171 of file ksock.cpp. References writeEvent(). Referenced by enableWrite(). |
|
Connected to the readNotifier. Called when the socket is ready for reading.
Definition at line 160 of file ksock.cpp. References closeEvent(), and readEvent(). Referenced by enableRead(). |
The documentation for this class was generated from the following files: