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

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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qsocketnotifier.cpp -->
<head>
  <title>Qt 4.6: QSocketNotifier Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QSocketNotifier" />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<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>
<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>
</tr></table><h1 class="title">QSocketNotifier Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
</h1>
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor. <a href="#details">More...</a></p>
<pre> #include &lt;QSocketNotifier&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qsocketnotifier-members.html">List of all members, including inherited members</a></li>
<li><a href="qsocketnotifier-qt3.html">Qt 3 support members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<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>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<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>
<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>
<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>
<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>
<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>
</table>
<ul>
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<hr />
<a name="public-slots"></a>
<h2>Public Slots</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<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>
</table>
<ul>
<li><div bar="2" class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<hr />
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<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>
</table>
<ul>
<li><div bar="2" class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<hr />
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<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>
</table>
<ul>
<li><div bar="2" class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"></div>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor.</p>
<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>
<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>
<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>
<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>
<p>Finally, you can use the <a href="qsocketnotifier.html#socket">socket</a>() function to retrieve the socket identifier. Although the class is called QSocketNotifier, it is normally used for other types of devices than sockets. <a href="qtcpsocket.html">QTcpSocket</a> and <a href="qudpsocket.html">QUdpSocket</a> provide notification through signals, so there is normally no need to use a QSocketNotifier on them.</p>
<a name="notes-for-windows-users"></a>
<h3>Notes for Windows Users</h3>
<p>The socket passed to QSocketNotifier will become non-blocking, even if it was created as a blocking socket. The <a href="qsocketnotifier.html#activated">activated</a>() signal is sometimes triggered by high general activity on the host, even if there is nothing to read. A subsequent read from the socket can then fail, the error indicating that there is no data available (e.g&#x2e;, <tt>WSAEWOULDBLOCK</tt>). This is an operating system limitation, and not a bug in QSocketNotifier.</p>
<p>To ensure that the socket notifier handles read notifications correctly, follow these steps when you receive a notification:</p>
<ol type="1">
<li>Disable the notifier.</li>
<li>Read data from the socket.</li>
<li>Re-enable the notifier if you are interested in more data (such as after having written a new command to a remote server).</li>
</ol>
<p>To ensure that the socket notifier handles write notifications correctly, follow these steps when you receive a notification:</p>
<ol type="1">
<li>Disable the notifier.</li>
<li>Write as much data as you can (before <tt>EWOULDBLOCK</tt> is returned).</li>
<li>Re-enable notifier if you have more data to write.</li>
</ol>
<p><b>Further information:</b> On Windows, Qt always disables the notifier after getting a notification, and only re-enables it if more data is expected. For example, if data is read from the socket and it can be used to read more, or if reading or writing is not possible because the socket would block, in which case it is necessary to wait before attempting to read or write again.</p>
<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>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tag/QSocketNotifier/Type" />
<a name="//apple_ref/cpp/econst/QSocketNotifier/Read" />
<a name="//apple_ref/cpp/econst/QSocketNotifier/Write" />
<a name="//apple_ref/cpp/econst/QSocketNotifier/Exception" />
<h3 class="fn"><a name="Type-enum"></a>enum QSocketNotifier::Type</h3>
<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>
<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>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<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>
<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>
<tr><td valign="top"><tt>QSocketNotifier::Exception</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">An exception has occurred. We recommend against using this.</td></tr>
</table></p>
<p>See also <a href="qsocketnotifier.html#QSocketNotifier">QSocketNotifier</a>() and <a href="qsocketnotifier.html#type">type</a>().</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QSocketNotifier/QSocketNotifier" />
<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>
<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>
<p>It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers.</p>
<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>
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>() and <a href="qsocketnotifier.html#isEnabled">isEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/~QSocketNotifier" />
<h3 class="fn"><a name="dtor.QSocketNotifier"></a>QSocketNotifier::~QSocketNotifier ()</h3>
<p>Destroys this socket notifier.</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/activated" />
<h3 class="fn"><a name="activated"></a>void QSocketNotifier::activated ( int <i>socket</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<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>
<p>The socket identifier is passed in the <i>socket</i> parameter.</p>
<p>See also <a href="qsocketnotifier.html#type">type</a>() and <a href="qsocketnotifier.html#socket">socket</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/event" />
<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>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/isEnabled" />
<h3 class="fn"><a name="isEnabled"></a>bool QSocketNotifier::isEnabled () const</h3>
<p>Returns true if the notifier is enabled; otherwise returns false.</p>
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/setEnabled" />
<h3 class="fn"><a name="setEnabled"></a>void QSocketNotifier::setEnabled ( bool <i>enable</i> )&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>If <i>enable</i> is true, the notifier is enabled; otherwise the notifier is disabled.</p>
<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>
<p>Write notifiers should normally be disabled immediately after the <a href="qsocketnotifier.html#activated">activated</a>() signal has been emitted</p>
<p>See also <a href="qsocketnotifier.html#isEnabled">isEnabled</a>() and <a href="qsocketnotifier.html#activated">activated</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/socket" />
<h3 class="fn"><a name="socket"></a>int QSocketNotifier::socket () const</h3>
<p>Returns the socket identifier specified to the constructor.</p>
<p>See also <a href="qsocketnotifier.html#type">type</a>().</p>
<a name="//apple_ref/cpp/instm/QSocketNotifier/type" />
<h3 class="fn"><a name="type"></a><a href="qsocketnotifier.html#Type-enum">Type</a> QSocketNotifier::type () const</h3>
<p>Returns the socket event type specified to the constructor.</p>
<p>See also <a href="qsocketnotifier.html#socket">socket</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
<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>
</html>