.BI "virtual void \fBnewConnection\fR ( int socket ) = 0"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "QSocketDevice * \fBsocketDevice\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QServerSocket class provides a TCP-based server.
.PP
This class is a convenience class for accepting incoming TCP connections. You can specify the port or have QServerSocket pick one, and listen on just one address or on all the machine's addresses.
.PP
Using the API is very simple: subclass QServerSocket, call the constructor of your choice, and implement newConnection() to handle new incoming connections. There is nothing more to do.
.PP
(Note that due to lack of support in the underlying APIs, QServerSocket cannot accept or reject connections conditionally.)
.PP
See also QSocket, QSocketDevice, QHostAddress, QSocketNotifier, and Input/Output and Networking.
Creates a server socket object, that will serve the given \fIport\fR on all the addresses of this host. If \fIport\fR is 0, QServerSocket will pick a suitable port in a system-dependent manner. Use \fIbacklog\fR to specify how many pending connections the server can have.
.PP
The \fIparent\fR and \fIname\fR arguments are passed on to the QObject constructor.
.PP
\fBWarning:\fR On Tru64 Unix systems a value of 0 for \fIbacklog\fR means that you don't accept any connections at all; you should specify a value larger than 0.
Creates a server socket object, that will serve the given \fIport\fR only on the given \fIaddress\fR. Use \fIbacklog\fR to specify how many pending connections the server can have.
.PP
The \fIparent\fR and \fIname\fR arguments are passed on to the QObject constructor.
.PP
\fBWarning:\fR On Tru64 Unix systems a value of 0 for \fIbacklog\fR means that you don't accept any connections at all; you should specify a value larger than 0.
This constructor, in combination with setSocket(), allows us to use the QServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets under Unix).
.PP
The \fIparent\fR and \fIname\fR arguments are passed on to the QObject constructor.
This causes any backlogged connections (connections that have reached the host, but not yet been completely set up by calling QSocketDevice::accept()) to be severed.
.PP
Existing connections continue to exist; this only affects the acceptance of new connections.
Returns the address on which this object listens, or 0.0.0.0 if this object listens on more than one address. ok() must be TRUE before calling this function.
.PP
See also port() and QSocketDevice::address().
.SH "void QServerSocket::newConnection ( int socket )\fC [pure virtual]\fR"
This pure virtual function is responsible for setting up a new incoming connection. \fIsocket\fR is the fd (file descriptor) for the newly accepted connection.
.SH "bool QServerSocket::ok () const"
Returns TRUE if the construction succeeded; otherwise returns FALSE.
Returns the port number on which this server socket listens. This is always non-zero; if you specify 0 in the constructor, QServerSocket will pick a non-zero port itself. ok() must be TRUE before calling this function.
.PP
See also address() and QSocketDevice::port().
.PP
Example: network/httpd/httpd.cpp.
.SH "void QServerSocket::setSocket ( int socket )\fC [virtual]\fR"
Sets the socket to use \fIsocket\fR. bind() and listen() should already have been called for \fIsocket\fR.
.PP
This allows us to use the QServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets).