You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/man/man3/tqserversocket.3qt

143 lines
6.5 KiB

'\" t
.TH TQServerSocket 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQServerSocket \- TCP-based server
.SH SYNOPSIS
\fC#include <tqserversocket.h>\fR
.PP
Inherits TQObject.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQServerSocket\fR ( TQ_UINT16 port, int backlog = 1, TQObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fBTQServerSocket\fR ( const TQHostAddress & address, TQ_UINT16 port, int backlog = 1, TQObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fBTQServerSocket\fR ( TQObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual \fB~TQServerSocket\fR ()"
.br
.ti -1c
.BI "bool \fBok\fR () const"
.br
.ti -1c
.BI "TQ_UINT16 \fBport\fR () const"
.br
.ti -1c
.BI "int \fBsocket\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetSocket\fR ( int socket )"
.br
.ti -1c
.BI "TQHostAddress \fBaddress\fR () const"
.br
.ti -1c
.BI "virtual void \fBnewConnection\fR ( int socket ) = 0"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "TQSocketDevice * \fBsocketDevice\fR ()"
.br
.in -1c
.SH DESCRIPTION
The TQServerSocket 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 TQServerSocket pick one, and listen on just one address or on all the machine's addresses.
.PP
Using the API is very simple: subclass TQServerSocket, 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, TQServerSocket cannot accept or reject connections conditionally.)
.PP
See also TQSocket, TQSocketDevice, TQHostAddress, TQSocketNotifier, and Input/Output and Networking.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQServerSocket::TQServerSocket ( TQ_UINT16 port, int backlog = 1, TQObject * parent = 0, const char * name = 0 )"
Creates a server socket object, that will serve the given \fIport\fR on all the addresses of this host. If \fIport\fR is 0, TQServerSocket 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 TQObject 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.
.SH "TQServerSocket::TQServerSocket ( const TQHostAddress & address, TQ_UINT16 port, int backlog = 1, TQObject * parent = 0, const char * name = 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 TQObject 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.
.SH "TQServerSocket::TQServerSocket ( TQObject * parent = 0, const char * name = 0 )"
Construct an empty server socket.
.PP
This constructor, in combination with setSocket(), allows us to use the TQServerSocket 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 TQObject constructor.
.PP
See also setSocket().
.SH "TQServerSocket::~TQServerSocket ()\fC [virtual]\fR"
Destroys the socket.
.PP
This causes any backlogged connections (connections that have reached the host, but not yet been completely set up by calling TQSocketDevice::accept()) to be severed.
.PP
Existing connections continue to exist; this only affects the acceptance of new connections.
.SH "TQHostAddress TQServerSocket::address () const"
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 TQSocketDevice::address().
.SH "void TQServerSocket::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 TQServerSocket::ok () const"
Returns TRUE if the construction succeeded; otherwise returns FALSE.
.SH "TQ_UINT16 TQServerSocket::port () const"
Returns the port number on which this server socket listens. This is always non-zero; if you specify 0 in the constructor, TQServerSocket will pick a non-zero port itself. ok() must be TRUE before calling this function.
.PP
See also address() and TQSocketDevice::port().
.PP
Example: network/httpd/httpd.cpp.
.SH "void TQServerSocket::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 TQServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets).
.SH "int TQServerSocket::socket () const"
Returns the operating system socket.
.SH "TQSocketDevice * TQServerSocket::socketDevice ()\fC [protected]\fR"
Returns a pointer to the internal socket device. The returned pointer is 0 if there is no connection or pending connection.
.PP
There is normally no need to manipulate the socket device directly
since this class does all the necessary setup for most client or
server socket applications.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqserversocket.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqserversocket.3qt) and the Qt
version (3.3.8).