📄 qserversocket.3qt
字号:
'\" t.TH QServerSocket 3qt "24 January 2005" "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.br.PP\fC#include <qserversocket.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQServerSocket\fR ( Q_UINT16 " "port" ", int " "backlog" " = 0, QObject * " "parent" "=0, const char * " "name" "=0 ) ".br.ti -1c.BI "\fBQServerSocket\fR ( const QHostAddress & " "address" ", Q_UINT16 " "port" ", int " "backlog" " = 0, 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 ) ".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 port or have QSocketServer pick one, and listen on just one address or on all the addresses of the machine..PPThe API is very simple: Subclass it, 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 and QSocketNotifier..SH MEMBER FUNCTION DOCUMENTATION.SH "QServerSocket::QServerSocket ( QObject * parent=0, const char * name=0 )"Construct an empty server socket..PPThis constructor in combination with setSocket() allows one to use the QServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets under Unix)..PPSee also setSocket()..SH "QServerSocket::QServerSocket ( Q_UINT16 port, int backlog = 0, 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 picks a suitable port in in a system-dependent manner. With \fIbacklog\fR you can specify how many pending connections a server can have..PPThe \fIparent\fR and \fIname\fR arguments are passed on as usual 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 = 0, QObject * parent=0, const char * name=0 )"Creates a server socket object, that will serve the given \fIport\fR on just \fIaddress.\fR With \fIbacklog\fR you can specify how many pending connections a server can have..PPThe \fIparent\fR and \fIname\fR arguments are passed on as usual 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 () \fC[virtual]\fR"Destructs the socket..PPThis brutally severes any backlogged connections (connections that have reached the host, but not yet been completely set up by calling QSocketDevice::accept())..PPExisting connections continue to exist; this only affects 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[virtual]\fR"This pure virtual function is responsible for setting up a new incoming connection. \fIsocket\fR is the fd of the newly accepted connection..SH "bool QServerSocket::ok () const"Tests that the construction succeeded..SH "Q_UINT16 QServerSocket::port () const"Returns the port number on which this object listens. This is always non-zero; if you specify 0 in the constructor, QServerSocket picks a port itself and port() returns its number. ok() must be TRUE before calling this function..PPSee also address() and QSocketDevice::port()..SH "void QServerSocket::setSocket ( int socket ) \fC[virtual]\fR"Sets the socket to use \fIsocket.\fR bind() and listen() should already be called For this socket..PPThis allows one to use the QServerSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets under Unix)..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 null if there is no connection or pending connection..PPThere is normally no need to manipulate the socket device directly since thisclass does all the necessary setup for most client or server socketapplications..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 make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qserversocket.3qt) and the Qtversion (2.3.10).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -