1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the network module 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
****************************************************************************/
29
#ifndef QSOCKETLAYER_P_H
30
#define QSOCKETLAYER_P_H
32
#include <qhostaddress.h>
33
#include <qabstractsocket.h>
35
class QSocketLayerPrivate;
41
NonBlockingSocketOption,
42
BroadcastSocketOption,
43
ReceiveBufferSocketOption,
44
SendBufferSocketOption,
51
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
52
bool initialize(int socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
53
QAbstractSocket::SocketType socketType() const;
54
QAbstractSocket::NetworkLayerProtocol protocol() const;
55
int socketDescriptor() const;
59
bool connectToHost(const QHostAddress &address, quint16 port);
60
bool bind(const QHostAddress &address, quint16 port);
65
qint64 bytesAvailable() const;
67
qint64 read(char *data, qint64 maxlen);
68
qint64 write(const char *data, qint64 len);
70
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
72
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
74
bool hasPendingDatagrams() const;
75
qint64 pendingDatagramSize() const;
77
QAbstractSocket::SocketState state() const;
79
QHostAddress localAddress() const;
80
quint16 localPort() const;
81
QHostAddress peerAddress() const;
82
quint16 peerPort() const;
84
qint64 receiveBufferSize() const;
85
void setReceiveBufferSize(qint64 bufferSize);
87
qint64 sendBufferSize() const;
88
void setSendBufferSize(qint64 bufferSize);
91
int option(SocketOption option) const;
92
bool setOption(SocketOption option, int value);
94
bool waitForRead(int msecs = 30000, bool *timedOut = 0) const;
95
bool waitForWrite(int msecs = 30000, bool *timedOut = 0) const;
96
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite,
97
bool checkRead, bool checkWrite,
98
int msecs = 30000, bool *timedOut = 0) const;
100
QAbstractSocket::SocketError error() const;
101
QString errorString() const;
104
Q_DISABLE_COPY(QSocketLayer)
106
QSocketLayerPrivate *d;
110
class QWindowsSockInit
119
class QSocketLayerPrivate
122
QSocketLayerPrivate();
123
~QSocketLayerPrivate();
125
int socketDescriptor;
127
QAbstractSocket::SocketType socketType;
128
QAbstractSocket::NetworkLayerProtocol socketProtocol;
129
QAbstractSocket::SocketState socketState;
130
mutable QAbstractSocket::SocketError socketError;
131
mutable QString socketErrorString;
133
QHostAddress peerAddress;
136
QHostAddress localAddress;
141
QWindowsSockInit winSock;
145
NonBlockingInitFailedErrorString,
146
BroadcastingInitFailedErrorString,
148
RemoteHostClosedErrorString,
151
OperationUnsupportedErrorString,
152
ProtocolUnsupportedErrorString,
153
InvalidSocketErrorString,
154
UnreachableErrorString,
156
ConnectionTimeOutErrorString,
157
ConnectionRefusedErrorString,
158
AddressInuseErrorString,
159
AddressNotAvailableErrorString,
160
AddressProtectedErrorString,
161
DatagramTooLargeErrorString,
162
SendDatagramErrorString,
163
ReceiveDatagramErrorString,
169
void setError(QAbstractSocket::SocketError error, ErrorString errorString) const;
172
int option(QSocketLayer::SocketOption option) const;
173
bool setOption(QSocketLayer::SocketOption option, int value);
175
bool createNewSocket(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol);
177
bool nativeConnect(const QHostAddress &address, quint16 port);
178
bool nativeBind(const QHostAddress &address, quint16 port);
179
bool nativeListen(int backlog);
181
qint64 nativeBytesAvailable() const;
183
bool nativeHasPendingDatagrams() const;
184
qint64 nativePendingDatagramSize() const;
185
qint64 nativeReceiveDatagram(char *data, qint64 maxLength,
186
QHostAddress *address, quint16 *port);
187
qint64 nativeSendDatagram(const char *data, qint64 length,
188
const QHostAddress &host, quint16 port);
189
qint64 nativeRead(char *data, qint64 maxLength);
190
qint64 nativeWrite(const char *data, qint64 length);
191
int nativeSelect(int timeout, bool selectForRead) const;
192
int nativeSelect(int timeout, bool checkRead, bool checkWrite,
193
bool *selectForRead, bool *selectForWrite) const;
197
bool fetchConnectionParameters();
202
#endif // QSOCKETLAYER_P_H