File: qserversocket.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (138 lines) | stat: -rw-r--r-- 8,722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QServerSocket Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QServerSocket Class Reference<br><small>[ <a href="network.html">network module</a> ]</small></h1><br clear="all">
<p>
The QServerSocket class provides a TCP-based server.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qserversocket-h.html">qserversocket.h</a>&gt;</code>
<p>
Inherits <a href="qobject.html">QObject</a>.
<p><a href="qserversocket-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#d0d4e1"><b>QServerSocket</b></a>(Q_UINT16port, intbacklog=0, QObject*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#022b79"><b>QServerSocket</b></a>(constQHostAddress&amp;address, Q_UINT16port, intbacklog=0, QObject*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#3d004a"><b>QServerSocket</b></a>(QObject*parent=0, constchar*name=0)</div>
<li><div class="fn">virtual<a href="#11dc72"><b>~QServerSocket</b></a>()</div>
<li><div class="fn">bool<a href="#2da8a0"><b>ok</b></a>()const</div>
<li><div class="fn">Q_UINT16<a href="#0cc99a"><b>port</b></a>()const</div>
<li><div class="fn">int<a href="#246a71"><b>socket</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#b39bd3"><b>setSocket</b></a>(intsocket)</div>
<li><div class="fn">QHostAddress<a href="#34c42d"><b>address</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#92d629"><b>newConnection</b></a>(intsocket)</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">QSocketDevice*<a href="#e859fa"><b>socketDevice</b></a>()</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QServerSocket class provides a TCP-based server.
<p>
This 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.
<p>The API is very simple: Subclass it, call the constructor of your
choice, and implement <a href="#92d629">newConnection</a>() to handle new incoming
connections.  There is nothing more to do.
<p>(Note that due to lack of support in the underlying APIs,
QServerSocket cannot accept or reject connections conditionally.)
<p>See also  <a href="qsocket.html">QSocket</a>, <a href="qsocketdevice.html">QSocketDevice</a>, <a href="qhostaddress.html">QHostAddress</a> and <a href="qsocketnotifier.html">QSocketNotifier</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="3d004a"></a>QServerSocket::QServerSocket(<a href="qobject.html">QObject</a>*parent=0, constchar*name=0)</h3>
<p>Construct an empty server socket.
<p>This constructor in combination with <a href="#b39bd3">setSocket</a>() allows one to use the
QServerSocket class as a wrapper for other socket types (e.g. Unix Domain
Sockets under Unix).
<p>See also  <a href="#b39bd3">setSocket</a>().
<h3 class="fn"><a name="d0d4e1"></a>QServerSocket::QServerSocket(Q_UINT16port, intbacklog=0, <a href="qobject.html">QObject</a>*parent=0, constchar*name=0)</h3>
<p>Creates a server socket object, that will serve the given <em>port</em> on
all the addresses of this host.  If <em>port</em> is 0, QServerSocket
picks a suitable port in in a system-dependent manner. With <em>backlog</em> you
can specify how many pending connections a server can have.
<p>The <em>parent</em> and <em>name</em> arguments are passed on as usual
to the <a href="qobject.html">QObject</a> constructor.<p><b>Warning:</b> On Tru64 Unix systems a value of 0 for <em>backlog</em> means that you
don't accept any connections at all; you should specify a value larger than
0.
<h3 class="fn"><a name="022b79"></a>QServerSocket::QServerSocket(const<a href="qhostaddress.html">QHostAddress</a>&amp;address, Q_UINT16port, intbacklog=0, <a href="qobject.html">QObject</a>*parent=0, constchar*name=0)</h3>
<p>Creates a server socket object, that will serve the given <em>port</em>
on just <em>address.</em> With <em>backlog</em> you can specify how many pending
connections a server can have.
<p>The <em>parent</em> and <em>name</em> arguments are passed on as usual
to the <a href="qobject.html">QObject</a> constructor.<p><b>Warning:</b> On Tru64 Unix systems a value of 0 for <em>backlog</em> means that you
don't accept any connections at all; you should specify a value larger than
0.
<h3 class="fn"><a name="11dc72"></a>QServerSocket::~QServerSocket() <code>[virtual]</code></h3>
<p>Destructs the socket.
<p>This brutally severes any backlogged connections (connections that
have reached the host, but not yet been completely set up by calling
<a href="qsocketdevice.html#8cb9cd">QSocketDevice::accept</a>()).
<p>Existing connections continue to exist; this only affects acceptance
of new connections.
<h3 class="fn"><a href="qhostaddress.html">QHostAddress</a><a name="34c42d"></a>QServerSocket::address()const</h3>
<p>Returns the address on which this object listens, or 0.0.0.0 if
this object listens on more than one address. <a href="#2da8a0">ok</a>() must be TRUE before
calling this function.
<p>See also  <a href="#0cc99a">port</a>() and <a href="qsocketdevice.html#ef3dd3">QSocketDevice::address</a>().
<h3 class="fn">void<a name="92d629"></a>QServerSocket::newConnection(intsocket) <code>[virtual]</code></h3>
<p>This pure virtual function is responsible for setting up a new
incoming connection.  <em>socket</em> is the fd of the newly accepted
connection.
<h3 class="fn">bool<a name="2da8a0"></a>QServerSocket::ok()const</h3>
<p>Tests that the construction succeeded.
<h3 class="fn">Q_UINT16<a name="0cc99a"></a>QServerSocket::port()const</h3>
<p>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. <a href="#2da8a0">ok</a>() must be TRUE before
calling this function.
<p>See also  <a href="#34c42d">address</a>() and <a href="qsocketdevice.html#07f655">QSocketDevice::port</a>().
<h3 class="fn">void<a name="b39bd3"></a>QServerSocket::setSocket(intsocket) <code>[virtual]</code></h3>
<p>Sets the socket to use <em>socket.</em> bind() and listen() should already be
called For this socket.
<p>This allows one to use the QServerSocket class as a wrapper for other socket
types (e.g. Unix Domain Sockets under Unix).
<h3 class="fn">int<a name="246a71"></a>QServerSocket::socket()const</h3>
<p>Returns the operating system socket.
<h3 class="fn"><a href="qsocketdevice.html">QSocketDevice</a>*<a name="e859fa"></a>QServerSocket::socketDevice() <code>[protected]</code></h3>
<p>Returns a pointer to the internal socket device. The returned pointer is
null if there is no connection or pending connection.
<p>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.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>