1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
33
#include "QtCore/qiodevice.h"
34
#include "QtNetwork/qhostaddress.h" // int->QHostAddress conversion
37
class Q3SocketPrivate;
40
class Q_COMPAT_EXPORT Q3Socket : public QIODevice
50
Q3Socket( QObject *parent=0, const char *name=0 );
53
enum State { Idle, HostLookup, Connecting,
55
Connection=Connected };
59
virtual void setSocket( int );
61
Q3SocketDevice *socketDevice();
62
virtual void setSocketDevice( Q3SocketDevice * );
65
virtual void connectToHost( const QString &host, Q_UINT16 port );
67
QString peerName() const;
69
// Implementation of QIODevice abstract virtual functions
70
bool open( int mode );
78
qint64 bytesAvailable() const;
79
Q_ULONG waitForMore( int msecs, bool *timeout ) const;
80
Q_ULONG waitForMore( int msecs ) const; // ### Qt 4.0: merge the two overloads
81
qint64 bytesToWrite() const;
82
void clearPendingData();
88
bool canReadLine() const;
90
Q_UINT16 port() const;
91
Q_UINT16 peerPort() const;
92
QHostAddress address() const;
93
QHostAddress peerAddress() const;
95
void setReadBufferSize( Q_ULONG );
96
Q_ULONG readBufferSize() const;
98
inline bool isSequential() const { return !isOpen(); }
103
void connectionClosed();
104
void delayedCloseFinished();
106
void bytesWritten( int nbytes );
110
virtual void sn_read( bool force=false );
111
virtual void sn_write();
114
qint64 readData(char *data, qint64 maxlen);
115
qint64 writeData(const char *data, qint64 len);
118
void tryConnecting();
119
void emitErrorConnectionRefused();
124
bool consumeWriteBuf( Q_ULONG nbytes );
125
void tryConnection();
126
void setSocketIntern( int socket );
128
private: // Disabled copy constructor and operator=
129
#if defined(Q_DISABLE_COPY)
130
Q3Socket( const Q3Socket & );
131
Q3Socket &operator=( const Q3Socket & );