2 * Copyright (C) 2004,2005 Thiago Macieira <thiago@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef KSOCKSSOCKETDEVICE_H
21 #define KSOCKSSOCKETDEVICE_H
23 #include "k3socketdevice.h"
27 class KSocksSocketDevicePrivate
;
29 * @class KSocksSocketDevice k3sockssocketdevice.h k3sockssocketdevice.h
30 * @brief The low-level class for SOCKS proxying.
32 * This class reimplements several functions from KSocketDevice in order
33 * to implement SOCKS support.
35 * This works by using KSocks.
37 * @author Thiago Macieira <thiago@kde.org>
39 * @warning This code is untested!
40 * @deprecated Use KSocketFactory or KLocalSocket instead
42 class KDECORE_EXPORT KSocksSocketDevice
: public KSocketDevice
48 KSocksSocketDevice(const KSocketBase
* = 0L);
51 * Construct from a file descriptor.
53 explicit KSocksSocketDevice(int fd
);
58 virtual ~KSocksSocketDevice();
61 * Sets our capabilities.
63 virtual int capabilities() const;
68 virtual bool bind(const KResolverEntry
& address
);
71 * Overrides listening.
73 virtual bool listen(int backlog
);
76 * Overrides connection.
78 virtual bool connect(const KResolverEntry
& address
);
81 * Overrides accepting. The return type is specialized.
83 virtual KSocksSocketDevice
* accept();
88 virtual qint64
readBlock(char *data
, quint64 maxlen
);
93 * @todo (Thiago, you saw this coming) Actually document this.
94 * What is the @p from for?
96 virtual qint64
readBlock(char *data
, quint64 maxlen
, KSocketAddress
& from
);
101 virtual qint64
peekBlock(char *data
, quint64 maxlen
);
106 virtual qint64
peekBlock(char *data
, quint64 maxlen
, KSocketAddress
& from
);
111 virtual qint64
writeBlock(const char *data
, quint64 len
);
116 virtual qint64
writeBlock(const char *data
, quint64 len
, const KSocketAddress
& to
);
119 * Overrides getting socket address.
121 virtual KSocketAddress
localAddress() const;
124 * Overrides getting peer address.
126 virtual KSocketAddress
peerAddress() const;
129 * Overrides getting external address.
131 virtual KSocketAddress
externalAddress() const;
136 virtual bool poll(bool* input
, bool* output
, bool* exception
= 0L,
137 int timeout
= -1, bool* timedout
= 0L);
140 static void initSocks();
141 friend class KSocketDevice
;
142 KSocksSocketDevicePrivate
* const d
;
145 } // namespace KNetwork