.TH "KNetwork::KDatagramSocket" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KNetwork::KDatagramSocket \- A socket that operates on datagrams.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kdatagramsocket.h>\fP
.PP
Inherits \fBKNetwork::KClientSocketBase\fP.
.PP
Inherited by \fBKNetwork::KMulticastSocket\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKDatagramSocket\fP (\fBQObject\fP *\fBparent\fP=0L, const char *\fBname\fP=0L)"
.br
.ti -1c
.RI "virtual \fB~KDatagramSocket\fP ()"
.br
.ti -1c
.RI "virtual bool \fBbind\fP (const \fBQString\fP &node=QString::null, const \fBQString\fP &service=QString::null)"
.br
.ti -1c
.RI "virtual bool \fBbind\fP (const \fBKResolverEntry\fP &entry)"
.br
.ti -1c
.RI "virtual bool \fBconnect\fP (const \fBQString\fP &node=QString::null, const \fBQString\fP &service=QString::null)"
.br
.ti -1c
.RI "virtual bool \fBconnect\fP (const \fBKResolverEntry\fP &entry)"
.br
.ti -1c
.RI "virtual \fBKDatagramPacket\fP \fBreceive\fP ()"
.br
.ti -1c
.RI "virtual Q_LONG \fBsend\fP (const \fBKDatagramPacket\fP &packet)"
.br
.in -1c
.SH "Detailed Description"
.PP 
A socket that operates on datagrams. 

Unlike \fBKStreamSocket\fP, which operates on a connection-based stream socket (generally TCP), this class and its descendants operates on datagrams, which are normally connectionless.
.PP
This class in specific provides easy access to the system's connectionless SOCK_DGRAM sockets.
.PP
\fBAuthor:\fP
.RS 4
Thiago Macieira <thiago.macieira@kdemail.net> 
.RE
.PP

.PP
Definition at line 180 of file kdatagramsocket.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KDatagramSocket::KDatagramSocket (\fBQObject\fP * parent = \fC0L\fP, const char * name = \fC0L\fP)"
.PP
Default constructor. 
.PP
Definition at line 44 of file kdatagramsocket.cpp.
.PP
References QObject::connect(), KNetwork::KClientSocketBase::hostFound(), KNetwork::KClientSocketBase::localResolver(), KNetwork::KClientSocketBase::peerResolver(), KNetwork::KResolver::setFamily(), KNetwork::KResolver::setFlags(), and KNetwork::KResolver::setSocketType().
.SS "KDatagramSocket::~\fBKDatagramSocket\fP ()\fC [virtual]\fP"
.PP
Destructor. 
.PP
This closes the socket. 
.PP
Definition at line 62 of file kdatagramsocket.cpp.
.SH "Member Function Documentation"
.PP 
.SS "bool KDatagramSocket::bind (const \fBQString\fP & node = \fCQString::null\fP, const \fBQString\fP & service = \fCQString::null\fP)\fC [virtual]\fP"
.PP
Binds this socket to the given address. 
.PP
If the socket is blocking, the socket will be bound when this function returns.
.PP
Note that binding a socket is not necessary to be able to send datagrams. Some protocol families will use anonymous source addresses, while others will allocate an address automatically. 
.PP
Implements \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 69 of file kdatagramsocket.cpp.
.PP
References KNetwork::KResolver::cancel(), KNetwork::KClientSocketBase::localResolver(), KNetwork::KClientSocketBase::lookup(), KNetwork::KResolver::setAddress(), and KNetwork::KClientSocketBase::state().
.SS "virtual bool KNetwork::KDatagramSocket::bind (const \fBKResolverEntry\fP & entry)\fC [inline, virtual]\fP"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Binds this socket to the given address. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 215 of file kdatagramsocket.h.
.SS "bool KDatagramSocket::connect (const \fBQString\fP & node = \fCQString::null\fP, const \fBQString\fP & service = \fCQString::null\fP)\fC [virtual]\fP"
.PP
'Connects' this socket to the given address. 
.PP
Note that connecting a datagram socket normally does not establish a permanent connection with the peer nor normally returns an error in case of failure.
.PP
Connecting means only to designate the given address as the default destination address for datagrams sent without destination addresses (\fBwriteBlock(const char*, Q_LONG)\fP.
.PP
\fBNote:\fP
.RS 4
Calling connect will not cause the socket to be bound. You have to call \fBbind\fP explicitly. 
.RE
.PP

.PP
Implements \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 92 of file kdatagramsocket.cpp.
.PP
References KNetwork::KClientSocketBase::lookup(), KNetwork::KClientSocketBase::peerResolver(), KNetwork::KResolver::setAddress(), KNetwork::KClientSocketBase::setState(), KNetwork::KClientSocketBase::state(), and KNetwork::KClientSocketBase::stateChanged().
.SS "virtual bool KNetwork::KDatagramSocket::connect (const \fBKResolverEntry\fP & entry)\fC [inline, virtual]\fP"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
'Connects' this socket to the given address. 
.PP
Reimplemented from \fBKNetwork::KClientSocketBase\fP.
.PP
Definition at line 237 of file kdatagramsocket.h.
.SS "\fBKDatagramPacket\fP KDatagramSocket::receive ()\fC [virtual]\fP"
.PP
Receives one datagram from the stream. 
.PP
The reading process is guaranteed to be atomical and not lose data from the packet.
.PP
If nothing could be read, a null object will be returned. 
.PP
Definition at line 134 of file kdatagramsocket.cpp.
.PP
References KNetwork::KSocketBase::blocking(), KNetwork::KClientSocketBase::bytesAvailable(), KNetwork::KClientSocketBase::gotError(), KNetwork::KClientSocketBase::readBlock(), KNetwork::KActiveSocketBase::setError(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KSocketDevice::waitForMore().
.SS "Q_LONG KDatagramSocket::send (const \fBKDatagramPacket\fP & packet)\fC [virtual]\fP"
.PP
Sends one datagram into the stream. 
.PP
The destination address must be set if this socket has not been connected (see \fBconnect\fP).
.PP
The data in this packet will be sent only in one single datagram. If the system cannot send it like that, this function will fail. So, please take into consideration the datagram size limits.
.PP
\fBReturns:\fP
.RS 4
the number of bytes written or -1 in case of error. 
.RE
.PP

.PP
Definition at line 168 of file kdatagramsocket.cpp.
.PP
References KNetwork::KClientSocketBase::writeBlock().

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