~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qsocketnotifier.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
<!DOCTYPE html
3
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
 
<!-- /fasttmp/mkdist-qt-4.5.2-1245473805/qt-x11-opensource-src-4.5.2/src/corelib/kernel/qsocketnotifier.cpp -->
 
5
<!-- qsocketnotifier.cpp -->
6
6
<head>
7
 
  <title>Qt 4.5: QSocketNotifier Class Reference</title>
 
7
  <title>Qt 4.6: QSocketNotifier Class Reference</title>
8
8
  <link href="classic.css" rel="stylesheet" type="text/css" />
9
9
</head>
10
10
<body>
 
11
<a name="//apple_ref/cpp/cl//QSocketNotifier" />
11
12
<table border="0" cellpadding="0" cellspacing="0" width="100%">
12
13
<tr>
13
 
<td align="left" valign="top" width="32"><a href="http://qtsoftware.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
 
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="namespaces.html"><font color="#004faf">All&nbsp;Namespaces</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
15
 
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QSocketNotifier Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
 
14
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
15
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
 
16
</tr></table><h1 class="title">QSocketNotifier Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
16
17
</h1>
17
18
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor. <a href="#details">More...</a></p>
18
19
<pre> #include &lt;QSocketNotifier&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
20
21
<li><a href="qsocketnotifier-members.html">List of all members, including inherited members</a></li>
21
22
<li><a href="qsocketnotifier-qt3.html">Qt 3 support members</a></li>
22
23
</ul>
 
24
<hr />
23
25
<a name="public-types"></a>
24
 
<h3>Public Types</h3>
25
 
<ul>
26
 
<li><div class="fn"></div>enum <b><a href="qsocketnotifier.html#Type-enum">Type</a></b> { Read, Write, Exception }</li>
27
 
</ul>
 
26
<h2>Public Types</h2>
 
27
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
28
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#Type-enum">Type</a></b> { Read, Write, Exception }</td></tr>
 
29
</table>
 
30
<hr />
28
31
<a name="public-functions"></a>
29
 
<h3>Public Functions</h3>
30
 
<ul>
31
 
<li><div class="fn"></div><b><a href="qsocketnotifier.html#QSocketNotifier">QSocketNotifier</a></b> ( int <i>socket</i>, Type <i>type</i>, QObject * <i>parent</i> = 0 )</li>
32
 
<li><div class="fn"></div><b><a href="qsocketnotifier.html#dtor.QSocketNotifier">~QSocketNotifier</a></b> ()</li>
33
 
<li><div class="fn"></div>bool <b><a href="qsocketnotifier.html#isEnabled">isEnabled</a></b> () const</li>
34
 
<li><div class="fn"></div>int <b><a href="qsocketnotifier.html#socket">socket</a></b> () const</li>
35
 
<li><div class="fn"></div>Type <b><a href="qsocketnotifier.html#type">type</a></b> () const</li>
36
 
</ul>
37
 
<ul>
38
 
<li><div class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
39
 
</ul>
 
32
<h2>Public Functions</h2>
 
33
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
34
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#QSocketNotifier">QSocketNotifier</a></b> ( int <i>socket</i>, Type <i>type</i>, QObject * <i>parent</i> = 0 )</td></tr>
 
35
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#dtor.QSocketNotifier">~QSocketNotifier</a></b> ()</td></tr>
 
36
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#isEnabled">isEnabled</a></b> () const</td></tr>
 
37
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#socket">socket</a></b> () const</td></tr>
 
38
<tr><td class="memItemLeft" align="right" valign="top">Type </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#type">type</a></b> () const</td></tr>
 
39
</table>
 
40
<ul>
 
41
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
42
</ul>
 
43
<hr />
40
44
<a name="public-slots"></a>
41
 
<h3>Public Slots</h3>
42
 
<ul>
43
 
<li><div class="fn"></div>void <b><a href="qsocketnotifier.html#setEnabled">setEnabled</a></b> ( bool <i>enable</i> )</li>
44
 
</ul>
45
 
<ul>
46
 
<li><div class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
47
 
</ul>
 
45
<h2>Public Slots</h2>
 
46
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
47
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#setEnabled">setEnabled</a></b> ( bool <i>enable</i> )</td></tr>
 
48
</table>
 
49
<ul>
 
50
<li><div bar="2" class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
51
</ul>
 
52
<hr />
48
53
<a name="signals"></a>
49
 
<h3>Signals</h3>
 
54
<h2>Signals</h2>
 
55
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
56
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#activated">activated</a></b> ( int <i>socket</i> )</td></tr>
 
57
</table>
50
58
<ul>
51
 
<li><div class="fn"></div>void <b><a href="qsocketnotifier.html#activated">activated</a></b> ( int <i>socket</i> )</li>
 
59
<li><div bar="2" class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
52
60
</ul>
 
61
<hr />
 
62
<a name="reimplemented-protected-functions"></a>
 
63
<h2>Reimplemented Protected Functions</h2>
 
64
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
 
65
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qsocketnotifier.html#event">event</a></b> ( QEvent * <i>e</i> )</td></tr>
 
66
</table>
53
67
<ul>
54
 
<li><div class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
68
<li><div bar="2" class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
55
69
</ul>
56
70
<h3>Additional Inherited Members</h3>
57
71
<ul>
63
77
<hr />
64
78
<h2>Detailed Description</h2>
65
79
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor.</p>
66
 
<p>The QSocketNotifier makes it possible to integrate Qt's event loop with other event loops based on file descriptors. For example, the <a href="http://www.qtsoftware.com/products/add-on-products/catalog/4/Utilities/qtcorba/">CORBA Framework</a> uses it to process CORBA events. File descriptor action is detected in Qt's main event loop (<a href="qcoreapplication.html#exec">QCoreApplication::exec</a>()).</p>
 
80
<p>The QSocketNotifier makes it possible to integrate Qt's event loop with other event loops based on file descriptors. For example, the <a href="http://qt.nokia.com/products/add-on-products/catalog/4/Utilities/qtcorba/">CORBA Framework</a> uses it to process CORBA events. File descriptor action is detected in Qt's main event loop (<a href="qcoreapplication.html#exec">QCoreApplication::exec</a>()).</p>
67
81
<a name="write-notifiers"></a><p>Once you have opened a device using a low-level (usually platform-specific) API, you can create a socket notifier to monitor the file descriptor. The socket notifier is enabled by default, i.e&#x2e; it emits the <a href="qsocketnotifier.html#activated">activated</a>() signal whenever a socket event corresponding to its type occurs. Connect the <a href="qsocketnotifier.html#activated">activated</a>() signal to the slot you want to be called when an event corresponding to your socket notifier's type occurs.</p>
68
82
<p>There are three types of socket notifiers: read, write, and exception. The type is described by the <a href="qsocketnotifier.html#Type-enum">Type</a> enum, and must be specified when constructing the socket notifier. After construction it can be determined using the <a href="qsocketnotifier.html#type">type</a>() function. Note that if you need to monitor both reads and writes for the same file descriptor, you must create two socket notifiers. Note also that it is not possible to install two socket notifiers of the same type (<a href="qsocketnotifier.html#Type-enum">Read</a>, <a href="qsocketnotifier.html#Type-enum">Write</a>, <a href="qsocketnotifier.html#Type-enum">Exception</a>) on the same socket.</p>
69
83
<p>The <a href="qsocketnotifier.html#setEnabled">setEnabled</a>() function allows you to disable as well as enable the socket notifier. It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers. A disabled notifier ignores socket events (the same effect as not creating the socket notifier). Use the <a href="qsocketnotifier.html#isEnabled">isEnabled</a>() function to determine the notifier's current status.</p>
87
101
<p>See also <a href="qfile.html">QFile</a>, <a href="qprocess.html">QProcess</a>, <a href="qtcpsocket.html">QTcpSocket</a>, and <a href="qudpsocket.html">QUdpSocket</a>.</p>
88
102
<hr />
89
103
<h2>Member Type Documentation</h2>
 
104
<a name="//apple_ref/cpp/tag/QSocketNotifier/Type" />
 
105
<a name="//apple_ref/cpp/econst/QSocketNotifier/Read" />
 
106
<a name="//apple_ref/cpp/econst/QSocketNotifier/Write" />
 
107
<a name="//apple_ref/cpp/econst/QSocketNotifier/Exception" />
90
108
<h3 class="fn"><a name="Type-enum"></a>enum QSocketNotifier::Type</h3>
91
109
<p>This enum describes the various types of events that a socket notifier can recognize. The type must be specified when constructing the socket notifier.</p>
92
110
<p>Note that if you need to monitor both reads and writes for the same file descriptor, you must create two socket notifiers. Note also that it is not possible to install two socket notifiers of the same type (Read, Write, Exception) on the same socket.</p>
93
 
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
 
111
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
94
112
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
95
113
<tr><td valign="top"><tt>QSocketNotifier::Read</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">There is data to be read.</td></tr>
96
114
<tr><td valign="top"><tt>QSocketNotifier::Write</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Data can be written.</td></tr>
99
117
<p>See also <a href="qsocketnotifier.html#QSocketNotifier">QSocketNotifier</a>() and <a href="qsocketnotifier.html#type">type</a>().</p>
100
118
<hr />
101
119
<h2>Member Function Documentation</h2>
 
120
<a name="//apple_ref/cpp/instm/QSocketNotifier/QSocketNotifier" />
102
121
<h3 class="fn"><a name="QSocketNotifier"></a>QSocketNotifier::QSocketNotifier ( int <i>socket</i>, <a href="qsocketnotifier.html#Type-enum">Type</a> <i>type</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
103
122
<p>Constructs a socket notifier with the given <i>parent</i>. It enables the <i>socket</i>, and watches for events of the given <i>type</i>.</p>
104
123
<p>It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers.</p>
105
124
<p><b>Note for Windows users:</b> The socket passed to <a href="qsocketnotifier.html">QSocketNotifier</a> will become non-blocking, even if it was created as a blocking socket.</p>
106
125
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>() and <a href="qsocketnotifier.html#isEnabled">isEnabled</a>().</p>
 
126
<a name="//apple_ref/cpp/instm/QSocketNotifier/~QSocketNotifier" />
107
127
<h3 class="fn"><a name="dtor.QSocketNotifier"></a>QSocketNotifier::~QSocketNotifier ()</h3>
108
128
<p>Destroys this socket notifier.</p>
 
129
<a name="//apple_ref/cpp/instm/QSocketNotifier/activated" />
109
130
<h3 class="fn"><a name="activated"></a>void QSocketNotifier::activated ( int <i>socket</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
110
131
<p>This signal is emitted whenever the socket notifier is enabled and a socket event corresponding to its <a href="qsocketnotifier.html#Type-enum">type</a> occurs.</p>
111
132
<p>The socket identifier is passed in the <i>socket</i> parameter.</p>
112
133
<p>See also <a href="qsocketnotifier.html#type">type</a>() and <a href="qsocketnotifier.html#socket">socket</a>().</p>
 
134
<a name="//apple_ref/cpp/instm/QSocketNotifier/event" />
 
135
<h3 class="fn"><a name="event"></a>bool QSocketNotifier::event ( <a href="qevent.html">QEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
136
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
 
137
<a name="//apple_ref/cpp/instm/QSocketNotifier/isEnabled" />
113
138
<h3 class="fn"><a name="isEnabled"></a>bool QSocketNotifier::isEnabled () const</h3>
114
139
<p>Returns true if the notifier is enabled; otherwise returns false.</p>
115
140
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>().</p>
 
141
<a name="//apple_ref/cpp/instm/QSocketNotifier/setEnabled" />
116
142
<h3 class="fn"><a name="setEnabled"></a>void QSocketNotifier::setEnabled ( bool <i>enable</i> )&nbsp;&nbsp;<tt> [slot]</tt></h3>
117
143
<p>If <i>enable</i> is true, the notifier is enabled; otherwise the notifier is disabled.</p>
118
144
<p>The notifier is enabled by default, i.e&#x2e; it emits the <a href="qsocketnotifier.html#activated">activated</a>() signal whenever a socket event corresponding to its <a href="qsocketnotifier.html#type">type</a> occurs. If it is disabled, it ignores socket events (the same effect as not creating the socket notifier).</p>
119
145
<p>Write notifiers should normally be disabled immediately after the <a href="qsocketnotifier.html#activated">activated</a>() signal has been emitted</p>
120
146
<p>See also <a href="qsocketnotifier.html#isEnabled">isEnabled</a>() and <a href="qsocketnotifier.html#activated">activated</a>().</p>
 
147
<a name="//apple_ref/cpp/instm/QSocketNotifier/socket" />
121
148
<h3 class="fn"><a name="socket"></a>int QSocketNotifier::socket () const</h3>
122
149
<p>Returns the socket identifier specified to the constructor.</p>
123
150
<p>See also <a href="qsocketnotifier.html#type">type</a>().</p>
 
151
<a name="//apple_ref/cpp/instm/QSocketNotifier/type" />
124
152
<h3 class="fn"><a name="type"></a><a href="qsocketnotifier.html#Type-enum">Type</a> QSocketNotifier::type () const</h3>
125
153
<p>Returns the socket event type specified to the constructor.</p>
126
154
<p>See also <a href="qsocketnotifier.html#socket">socket</a>().</p>
127
155
<p /><address><hr /><div align="center">
128
156
<table width="100%" cellspacing="0" border="0"><tr class="address">
129
 
<td width="30%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
130
 
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
131
 
<td width="30%" align="right"><div align="right">Qt 4.5.2</div></td>
132
 
</tr></table></div></address></body>
 
157
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
 
158
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
159
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
 
160
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>
133
161
</html>