⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qserversocket.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
字号:
'\" t.TH QServerSocket 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQServerSocket \- TCP-based server.SH SYNOPSIS\fC#include <qserversocket.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQServerSocket\fR ( Q_UINT16 port, int backlog = 1, QObject * parent = 0, const char * name = 0 )".br.ti -1c.BI "\fBQServerSocket\fR ( const QHostAddress & address, Q_UINT16 port, int backlog = 1, QObject * parent = 0, const char * name = 0 )".br.ti -1c.BI "\fBQServerSocket\fR ( QObject * parent = 0, const char * name = 0 )".br.ti -1c.BI "virtual \fB~QServerSocket\fR ()".br.ti -1c.BI "bool \fBok\fR () const".br.ti -1c.BI "Q_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 "QHostAddress \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 "QSocketDevice * \fBsocketDevice\fR ()".br.in -1c.SH DESCRIPTIONThe QServerSocket class provides a TCP-based server..PPThis 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..PPUsing 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.).PPSee also QSocket, QSocketDevice, QHostAddress, QSocketNotifier, and Input/Output and Networking..SH MEMBER FUNCTION DOCUMENTATION.SH "QServerSocket::QServerSocket ( Q_UINT16 port, int backlog = 1, QObject * 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, QServerSocket will pick a suitable port in a system-dependent manner. Use \fIbacklog\fR to specify how many pending connections the server can have..PPThe \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..SH "QServerSocket::QServerSocket ( const QHostAddress & address, Q_UINT16 port, int backlog = 1, QObject * 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..PPThe \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..SH "QServerSocket::QServerSocket ( QObject * parent = 0, const char * name = 0 )"Construct an empty server socket..PPThis 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)..PPThe \fIparent\fR and \fIname\fR arguments are passed on to the QObject constructor..PPSee also setSocket()..SH "QServerSocket::~QServerSocket ()\fC [virtual]\fR"Destroys the socket..PPThis causes any backlogged connections (connections that have reached the host, but not yet been completely set up by calling QSocketDevice::accept()) to be severed..PPExisting connections continue to exist; this only affects the acceptance of new connections..SH "QHostAddress QServerSocket::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..PPSee 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..SH "Q_UINT16 QServerSocket::port () const"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..PPSee also address() and QSocketDevice::port()..PPExample: 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..PPThis allows us to use the QServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets)..SH "int QServerSocket::socket () const"Returns the operating system socket..SH "QSocketDevice * QServerSocket::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..PPThere is normally no need to manipulate the socket device directlysince this class does all the necessary setup for most client orserver socket applications..SH "SEE ALSO".BR http://doc.trolltech.com/qserversocket.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qserversocket.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -