1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/kernel/qsocketnotifier.cpp -->
7
<title>Qt 4.0: QSocketNotifier Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QSocketNotifier Class Reference</h1>
21
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor. <a href="#details">More...</a></p>
22
<pre>#include <QSocketNotifier></pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
25
<li><a href="qsocketnotifier-members.html">List of all members, including inherited members</a></li>
26
<li><a href="qsocketnotifier-qt3.html">Qt 3 support members</a></li>
28
<a name="public-types"></a>
31
<li><div class="fn"/>enum <b><a href="qsocketnotifier.html#Type-enum">Type</a></b> { Read, Write, Exception }</li>
33
<a name="public-functions"></a>
34
<h3>Public Functions</h3>
36
<li><div class="fn"/><b><a href="qsocketnotifier.html#QSocketNotifier">QSocketNotifier</a></b> ( int <i>socket</i>, Type <i>type</i>, QObject * <i>parent</i> = 0 )</li>
37
<li><div class="fn"/><b><a href="qsocketnotifier.html#dtor.QSocketNotifier">~QSocketNotifier</a></b> ()</li>
38
<li><div class="fn"/>bool <b><a href="qsocketnotifier.html#isEnabled">isEnabled</a></b> () const</li>
39
<li><div class="fn"/>int <b><a href="qsocketnotifier.html#socket">socket</a></b> () const</li>
40
<li><div class="fn"/>Type <b><a href="qsocketnotifier.html#type">type</a></b> () const</li>
43
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
45
<a name="public-slots"></a>
48
<li><div class="fn"/>void <b><a href="qsocketnotifier.html#setEnabled">setEnabled</a></b> ( bool <i>enable</i> )</li>
51
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
53
<a name="signals"></a>
56
<li><div class="fn"/>void <b><a href="qsocketnotifier.html#activated">activated</a></b> ( int <i>socket</i> )</li>
59
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
61
<h3>Additional Inherited Members</h3>
63
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
64
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
65
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
67
<a name="details"></a>
69
<h2>Detailed Description</h2>
70
<p>The QSocketNotifier class provides support for monitoring activity on a file descriptor.</p>
71
<p>The QSocketNotifier makes it possible to integrate Qt's event loop with other event loops based on file descriptors. For example, the QtCorba Solution 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>
72
<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. You can then connect the <a href="qsocketnotifier.html#activated">activated</a>() signal to the slot you want to be called whenever an event occurs.</p>
73
<p>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>
74
<a name="write-notifiers"></a><p>There are three types of socket notifiers: read, write, and exception. You must specify one of these in the constructor.</p>
75
<p>The type specifies when the <a href="qsocketnotifier.html#activated">activated</a>() signal is to be emitted:</p>
77
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Read</a> - There is data to be read.</li>
78
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Write</a> - Data can be written.</li>
79
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Exception</a> - An exception has occurred. We recommend against using this.</li>
81
<p>If you need to monitor both reads and writes for the same file descriptor, you must create two socket notifiers.</p>
82
<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>
84
<h2>Member Type Documentation</h2>
85
<h3 class="fn"><a name="Type-enum"></a>enum QSocketNotifier::Type</h3>
86
<p>The socket notifier can be used to inform the application of the following types of event:</p>
87
<table border="1" cellpadding="2" cellspacing="1" width="100%">
88
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
89
<tr><td valign="top"><tt>QSocketNotifier::Read</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">There is incoming data.</td></tr>
90
<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>
91
<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.</td></tr>
94
<h2>Member Function Documentation</h2>
95
<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>
96
<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>
97
<p>It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers.</p>
98
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>() and <a href="qsocketnotifier.html#isEnabled">isEnabled</a>().</p>
99
<h3 class="fn"><a name="dtor.QSocketNotifier"></a>QSocketNotifier::~QSocketNotifier ()</h3>
100
<p>Destroys the socket notifier.</p>
101
<h3 class="fn"><a name="activated"></a>void QSocketNotifier::activated ( int <i>socket</i> ) <tt> [signal]</tt></h3>
102
<p>This signal is emitted under certain conditions specified by the notifier <a href="qsocketnotifier.html#type">type</a>():</p>
104
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Read</a> - There is data to be read (socket read event).</li>
105
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Write</a> - Data can be written (socket write event).</li>
106
<li><a href="qsocketnotifier.html#Type-enum">QSocketNotifier::Exception</a> - An exception has occurred (socket exception event).</li>
108
<p>The <i>socket</i> is the socket identifier.</p>
109
<p>See also <a href="qsocketnotifier.html#type">type</a>() and <a href="qsocketnotifier.html#socket">socket</a>().</p>
110
<h3 class="fn"><a name="isEnabled"></a>bool QSocketNotifier::isEnabled () const</h3>
111
<p>Returns true if the notifier is enabled; otherwise returns false.</p>
112
<p>See also <a href="qsocketnotifier.html#setEnabled">setEnabled</a>().</p>
113
<h3 class="fn"><a name="setEnabled"></a>void QSocketNotifier::setEnabled ( bool <i>enable</i> ) <tt> [slot]</tt></h3>
114
<p>If <i>enable</i> is true, the notifier is enabled; otherwise the notifier is disabled.</p>
115
<p>The notifier is enabled by default.</p>
116
<p>If the notifier is enabled, 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>
117
<p>Write notifiers should normally be disabled immediately after the <a href="qsocketnotifier.html#activated">activated</a>() signal has been emitted; see discussion of write notifiers in the <a href="qsocketnotifier.html#write-notifiers">class description</a> above.</p>
118
<p>See also <a href="qsocketnotifier.html#isEnabled">isEnabled</a>() and <a href="qsocketnotifier.html#activated">activated</a>().</p>
119
<h3 class="fn"><a name="socket"></a>int QSocketNotifier::socket () const</h3>
120
<p>Returns the socket identifier specified to the constructor.</p>
121
<p>See also <a href="qsocketnotifier.html#type">type</a>().</p>
122
<h3 class="fn"><a name="type"></a><a href="qsocketnotifier.html#Type-enum">Type</a> QSocketNotifier::type () const</h3>
123
<p>Returns the socket event type specified to the constructor.</p>
124
<p>See also <a href="qsocketnotifier.html#socket">socket</a>().</p>
125
<p /><address><hr /><div align="center">
126
<table width="100%" cellspacing="0" border="0"><tr class="address">
127
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
128
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
129
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
130
</tr></table></div></address></body>