KDELibs4Support

k3bufferedsocket.h
1 /* -*- C++ -*-
2  * Copyright (C) 2003,2005 Thiago Macieira <[email protected]>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KBUFFEREDSOCKET_H
26 #define KBUFFEREDSOCKET_H
27 
28 #include <kdelibs4support_export.h>
29 #include "k3streamsocket.h"
30 
31 #include <QObject>
32 #include <QByteArray>
33 #include <QList>
34 
35 namespace KNetwork
36 {
37 
38 class KBufferedSocketPrivate;
59 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KBufferedSocket: public KStreamSocket
60 {
61  Q_OBJECT
62 public:
70  KDELIBS4SUPPORT_DEPRECATED explicit KBufferedSocket(const QString &node = QString(), const QString &service = QString(),
71  QObject *parent = nullptr);
72 
76  virtual ~KBufferedSocket();
77 
81  void setSocketDevice(KSocketDevice *device) override;
82 
83 protected:
87  bool setSocketOptions(int opts) override;
88 
89 public:
96  void close() override;
97 
101  qint64 bytesAvailable() const override;
102 
106  qint64 waitForMore(int msecs, bool *timeout = nullptr) override;
107 
111  void enableRead(bool enable) override;
112 
116  void enableWrite(bool enable) override;
117 
121  void setInputBuffering(bool enable);
122 
126  void setOutputBuffering(bool enable);
127 
131  qint64 bytesToWrite() const override;
132 
139  virtual void closeNow();
140 
144  bool canReadLine() const override;
145 
146  // KDE4: make virtual, add timeout to match the Qt4 signature
147  // and move to another class up the hierarchy
152  void waitForConnect();
153 
154 protected:
160  qint64 readData(char *data, qint64 maxlen, KSocketAddress *from) override;
161 
167  qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from) override;
168 
174  qint64 writeData(const char *data, qint64 len, const KSocketAddress *to) override;
175 
179  qint64 readLineData(char *data, qint64 maxSize) override;
180 
184  void stateChanging(SocketState newState) override;
185 
186 protected Q_SLOTS:
190  void slotReadActivity() override;
191 
195  void slotWriteActivity() override;
196 
197 #if 0
198  // Already present in QIODevice
199 Q_SIGNALS:
203  void bytesWritten(int bytes);
204 #endif
205 
206 private:
207  KBufferedSocket(const KBufferedSocket &);
208  KBufferedSocket &operator=(const KBufferedSocket &);
209 
210  KBufferedSocketPrivate *const d;
211 };
212 
213 } // namespace KNetwork
214 
215 #endif
Simple stream socket.
A generic socket address.
A namespace to store all networking-related (socket) classes.
Buffered stream sockets.
Low-level socket functionality.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 22:59:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.