source: trunk/src/corelib/kernel/qsocketnotifier.cpp@ 991

Last change on this file since 991 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 10.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qsocketnotifier.h"
43
44#include "qplatformdefs.h"
45
46#include "qabstracteventdispatcher.h"
47#include "qcoreapplication.h"
48
49#include "qobject_p.h"
50#include <private/qthread_p.h>
51
52QT_BEGIN_NAMESPACE
53
54/*!
55 \class QSocketNotifier
56 \brief The QSocketNotifier class provides support for monitoring
57 activity on a file descriptor.
58
59 \ingroup network
60 \ingroup io
61
62 The QSocketNotifier makes it possible to integrate Qt's event
63 loop with other event loops based on file descriptors. For
64 example, the \l{CORBA Framework} uses it to process CORBA
65 events. File descriptor action is detected in Qt's main event
66 loop (QCoreApplication::exec()).
67
68 \target write notifiers
69
70 Once you have opened a device using a low-level (usually
71 platform-specific) API, you can create a socket notifier to
72 monitor the file descriptor. The socket notifier is enabled by
73 default, i.e. it emits the activated() signal whenever a socket
74 event corresponding to its type occurs. Connect the activated()
75 signal to the slot you want to be called when an event
76 corresponding to your socket notifier's type occurs.
77
78 There are three types of socket notifiers: read, write, and
79 exception. The type is described by the \l Type enum, and must be
80 specified when constructing the socket notifier. After
81 construction it can be determined using the type() function. Note
82 that if you need to monitor both reads and writes for the same
83 file descriptor, you must create two socket notifiers. Note also
84 that it is not possible to install two socket notifiers of the
85 same type (\l Read, \l Write, \l Exception) on the same socket.
86
87 The setEnabled() function allows you to disable as well as enable
88 the socket notifier. It is generally advisable to explicitly
89 enable or disable the socket notifier, especially for write
90 notifiers. A disabled notifier ignores socket events (the same
91 effect as not creating the socket notifier). Use the isEnabled()
92 function to determine the notifier's current status.
93