.TH "KSocket" 3 "28 Jan 2004" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KSocket \- You can connect this socket to any Internet address. A TCP/IP client socket.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <ksock.h>\fP
.PP
Inherits \fBQObject\fP.
.PP
.SS "Public Slots"

.in +1c
.ti -1c
.RI "void \fBslotWrite\fP (int x)"
.br
.RI "\fIConnected to the writeNotifier. \fP"
.ti -1c
.RI "void \fBslotRead\fP (int x)"
.br
.RI "\fIConnected to the readNotifier. \fP"
.in -1c
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBreadEvent\fP (\fBKSocket\fP *s)"
.br
.RI "\fIData has arrived for reading. \fP"
.ti -1c
.RI "void \fBwriteEvent\fP (\fBKSocket\fP *s)"
.br
.RI "\fISocket is ready for writing. \fP"
.ti -1c
.RI "void \fBcloseEvent\fP (\fBKSocket\fP *s)"
.br
.RI "\fIRaised when the connection is broken. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKSocket\fP (int _sock)"
.br
.RI "\fIConstructs a KSocket with the provided file descriptor. \fP"
.ti -1c
.RI "\fBKSocket\fP (const  char *_host, unsigned short int _port, int timeOut=30)"
.br
.RI "\fICreates a socket and connects to a host. \fP"
.ti -1c
.RI "\fBKSocket\fP (const  char *_path)"
.br
.RI "\fIConnects to a UNIX domain socket. \fP"
.ti -1c
.RI "virtual \fB~KSocket\fP ()"
.br
.RI "\fIDestructor. \fP"
.ti -1c
.RI "int \fBsocket\fP () const "
.br
.RI "\fIReturns a file descriptor for this socket. \fP"
.ti -1c
.RI "void \fBenableRead\fP (bool enable)"
.br
.RI "\fIEnables the socket for reading. \fP"
.ti -1c
.RI "void \fBenableWrite\fP (bool enable)"
.br
.RI "\fIEnables the socket for writing. \fP"
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "bool \fBconnect\fP (const  \fBQString\fP &_host, unsigned short int _port, int timeout=0)"
.br
.ti -1c
.RI "bool \fBconnect\fP (const  char *_path)"
.br
.in -1c
.SS "Protected Attributes"

.in +1c
.ti -1c
.RI "int \fBsock\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
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 \fBsocket\fP() you get a file descriptor which you can use with the usual UNIX function like \fBwrite\fP() or \fBread\fP(). If you have already such a socket identifier you can construct a KSocket on this identifier.
.PP
If \fBsocket\fP() delivers a value of -1 or less, the connection was not successful.
.PP
\fBAuthor:\fP
.RS 4
Torben Weis <weis@uni-frankfurt.de> 
.RE
.PP
\fBVersion:\fP
.RS 4
\fBId\fP.RS 4
\fBksock.h\fP,v 1.53 2002/09/09 21:24:53 tjansen Exp 
.RE
.PP
.RE
.PP

.PP
Definition at line 81 of file ksock.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KSocket::KSocket (int _sock)"
.PP
Constructs a KSocket with the provided file descriptor. \fBParameters:\fP
.RS 4
\fI_sock\fP The file descriptor to use. 
.RE
.PP
Definition at line 101 of file ksock.cpp.
.PP
References KSocks::getsockname(), and KSocks::self().
.SS "KSocket::KSocket (const char * _host, unsigned short int _port, int timeOut = 30)"
.PP
Creates a socket and connects to a host. \fBParameters:\fP
.RS 4
\fI_host\fP The remote host to which to connect. 
.br
\fI_port\fP The port on the remote host. 
.br
\fItimeOut\fP The number of seconds waiting for connect (default 30). 
.RE
.PP
Definition at line 115 of file ksock.cpp.
.PP
References QObject::connect().
.SS "KSocket::KSocket (const char * _path)"
.PP
Connects to a UNIX domain socket. \fBParameters:\fP
.RS 4
\fI_path\fP The filename of the socket. 
.RE
.PP
Definition at line 121 of file ksock.cpp.
.PP
References QObject::connect().
.SS "KSocket::~\fBKSocket\fP ()\fC [virtual]\fP"
.PP
Destructor. Closes the socket if it is still open. Definition at line 260 of file ksock.cpp.
.SH "Member Function Documentation"
.PP 
.SS "int KSocket::socket () const\fC [inline]\fP"
.PP
Returns a file descriptor for this socket. \fBReturns:\fP
.RS 4
the file descriptor, or -1 when an error occured. 
.RE
.PP
Definition at line 113 of file ksock.h.
.SS "void KSocket::enableRead (bool enable)"
.PP
Enables the socket for reading. If you enable read mode, the socket will emit the signal \fBreadEvent\fP() whenever there is something to read out of this socket. 
.PP
\fBParameters:\fP
.RS 4
\fIenable\fP true to enable reading signals 
.RE
.PP
Definition at line 127 of file ksock.cpp.
.PP
References QObject::connect(), and slotRead().
.SS "void KSocket::enableWrite (bool enable)"
.PP
Enables the socket for writing. If you enable write mode, the socket will emit the signal \fBwriteEvent\fP() whenever the socket is ready for writing.
.PP
Warning: If you forget to call enableWrite(false) when you are not ready to send data, you will get lots of \fBwriteEvent()\fP signals, in the order of thousands a second ! 
.PP
\fBParameters:\fP
.RS 4
\fIenable\fP true to enable writing signals 
.RE
.PP
Definition at line 143 of file ksock.cpp.
.PP
References QObject::connect(), and slotWrite().
.SS "void KSocket::readEvent (\fBKSocket\fP * s)\fC [signal]\fP"
.PP
Data has arrived for reading. This signal will only be raised if \fBenableRead\fP( \fCtrue\fP ) was called first. 
.PP
\fBParameters:\fP
.RS 4
\fIs\fP the KSocket that triggered the event 
.RE
.PP
Referenced by slotRead().
.SS "void KSocket::writeEvent (\fBKSocket\fP * s)\fC [signal]\fP"
.PP
Socket is ready for writing. This signal will only be raised if \fBenableWrite\fP( \fCtrue\fP ) was called first.
.PP
Warning: If you forget to call enableWrite(false) when you are not ready to send data, you will get lots of \fBwriteEvent()\fP signals, in the order of thousands a second ! 
.PP
\fBParameters:\fP
.RS 4
\fIs\fP the KSocket that triggered the event 
.RE
.PP
Referenced by slotWrite().
.SS "void KSocket::closeEvent (\fBKSocket\fP * s)\fC [signal]\fP"
.PP
Raised when the connection is broken. \fBParameters:\fP
.RS 4
\fIs\fP the KSocket that triggered the event 
.RE
.PP
Referenced by slotRead().
.SS "void KSocket::slotWrite (int x)\fC [slot]\fP"
.PP
Connected to the writeNotifier. Called when the socket is ready for writing. 
.PP
\fBParameters:\fP
.RS 4
\fIx\fP ignored 
.RE
.PP
Definition at line 171 of file ksock.cpp.
.PP
References writeEvent().
.PP
Referenced by enableWrite().
.SS "void KSocket::slotRead (int x)\fC [slot]\fP"
.PP
Connected to the readNotifier. Called when the socket is ready for reading. 
.PP
\fBParameters:\fP
.RS 4
\fIx\fP ignored 
.RE
.PP
Definition at line 160 of file ksock.cpp.
.PP
References closeEvent(), and readEvent().
.PP
Referenced by enableRead().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
