1QServerSocket(3qt)                                          QServerSocket(3qt)
2
3
4

NAME

6       QServerSocket - TCP-based server
7

SYNOPSIS

9       #include <qserversocket.h>
10
11       Inherits QObject.
12
13   Public Members
14       QServerSocket ( Q_UINT16 port, int backlog = 1, QObject * parent = 0,
15           const char * name = 0 )
16       QServerSocket ( const QHostAddress & address, Q_UINT16 port, int
17           backlog = 1, QObject * parent = 0, const char * name = 0 )
18       QServerSocket ( QObject * parent = 0, const char * name = 0 )
19       virtual ~QServerSocket ()
20       bool ok () const
21       Q_UINT16 port () const
22       int socket () const
23       virtual void setSocket ( int socket )
24       QHostAddress address () const
25       virtual void newConnection ( int socket ) = 0
26
27   Protected Members
28       QSocketDevice * socketDevice ()
29

DESCRIPTION

31       The QServerSocket class provides a TCP-based server.
32
33       This class is a convenience class for accepting incoming TCP
34       connections. You can specify the port or have QServerSocket pick one,
35       and listen on just one address or on all the machine's addresses.
36
37       Using the API is very simple: subclass QServerSocket, call the
38       constructor of your choice, and implement newConnection() to handle new
39       incoming connections. There is nothing more to do.
40
41       (Note that due to lack of support in the underlying APIs, QServerSocket
42       cannot accept or reject connections conditionally.)
43
44       See also QSocket, QSocketDevice, QHostAddress, QSocketNotifier, and
45       Input/Output and Networking.
46

MEMBER FUNCTION DOCUMENTATION

QServerSocket::QServerSocket ( Q_UINT16 port, int backlog = 1, QObject *

49       parent = 0, const char * name = 0 )
50       Creates a server socket object, that will serve the given port on all
51       the addresses of this host. If port is 0, QServerSocket will pick a
52       suitable port in a system-dependent manner. Use backlog to specify how
53       many pending connections the server can have.
54
55       The parent and name arguments are passed on to the QObject constructor.
56
57       Warning: On Tru64 Unix systems a value of 0 for backlog means that you
58       don't accept any connections at all; you should specify a value larger
59       than 0.
60

QServerSocket::QServerSocket ( const QHostAddress & address, Q_UINT16 port,

62       int backlog = 1, QObject * parent = 0, const char * name = 0 )
63       Creates a server socket object, that will serve the given port only on
64       the given address. Use backlog to specify how many pending connections
65       the server can have.
66
67       The parent and name arguments are passed on to the QObject constructor.
68
69       Warning: On Tru64 Unix systems a value of 0 for backlog means that you
70       don't accept any connections at all; you should specify a value larger
71       than 0.
72

QServerSocket::QServerSocket ( QObject * parent = 0, const char * name = 0 )

74       Construct an empty server socket.
75
76       This constructor, in combination with setSocket(), allows us to use the
77       QServerSocket class as a wrapper for other socket types (e.g. Unix
78       Domain Sockets under Unix).
79
80       The parent and name arguments are passed on to the QObject constructor.
81
82       See also setSocket().
83

QServerSocket::~QServerSocket () [virtual]

85       Destroys the socket.
86
87       This causes any backlogged connections (connections that have reached
88       the host, but not yet been completely set up by calling
89       QSocketDevice::accept()) to be severed.
90
91       Existing connections continue to exist; this only affects the
92       acceptance of new connections.
93

QHostAddress QServerSocket::address () const

95       Returns the address on which this object listens, or 0.0.0.0 if this
96       object listens on more than one address. ok() must be TRUE before
97       calling this function.
98
99       See also port() and QSocketDevice::address().
100

void QServerSocket::newConnection ( int socket ) [pure virtual]

102       This pure virtual function is responsible for setting up a new incoming
103       connection. socket is the fd (file descriptor) for the newly accepted
104       connection.
105

bool QServerSocket::ok () const

107       Returns TRUE if the construction succeeded; otherwise returns FALSE.
108

Q_UINT16 QServerSocket::port () const

110       Returns the port number on which this server socket listens. This is
111       always non-zero; if you specify 0 in the constructor, QServerSocket
112       will pick a non-zero port itself. ok() must be TRUE before calling this
113       function.
114
115       See also address() and QSocketDevice::port().
116
117       Example: network/httpd/httpd.cpp.
118

void QServerSocket::setSocket ( int socket ) [virtual]

120       Sets the socket to use socket. bind() and listen() should already have
121       been called for socket.
122
123       This allows us to use the QServerSocket class as a wrapper for other
124       socket types (e.g. Unix Domain Sockets).
125

int QServerSocket::socket () const

127       Returns the operating system socket.
128

QSocketDevice * QServerSocket::socketDevice () [protected]

130       Returns a pointer to the internal socket device. The returned pointer
131       is 0 if there is no connection or pending connection.
132
133       There is normally no need to manipulate the socket device directly
134       since this class does all the necessary setup for most client or server
135       socket applications.
136
137

SEE ALSO

139       http://doc.trolltech.com/qserversocket.html
140       http://www.trolltech.com/faq/tech.html
141
143       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
144       license file included in the distribution for a complete license
145       statement.
146

AUTHOR

148       Generated automatically from the source code.
149

BUGS

151       If you find a bug in Qt, please report it as described in
152       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
153       help you. Thank you.
154
155       The definitive Qt documentation is provided in HTML format; it is
156       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
157       web browser. This man page is provided as a convenience for those users
158       who prefer man pages, although this format is not officially supported
159       by Trolltech.
160
161       If you find errors in this manual page, please report them to qt-
162       bugs@trolltech.com.  Please include the name of the manual page
163       (qserversocket.3qt) and the Qt version (3.3.8).
164
165
166
167Trolltech AS                    2 February 2007             QServerSocket(3qt)
Impressum