• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • network
k3bufferedsocket.h
Go to the documentation of this file.
1/* -*- C++ -*-
2 * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
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 <kdecore_export.h>
29#include "k3streamsocket.h"
30
31#include <QtCore/QObject>
32#include <QtCore/QByteArray>
33#include <QtCore/QList>
34
35namespace KNetwork {
36
37class KBufferedSocketPrivate;
58class KDECORE_EXPORT_DEPRECATED KBufferedSocket: public KStreamSocket
59{
60 Q_OBJECT
61public:
69 explicit KBufferedSocket(const QString& node = QString(), const QString& service = QString(),
70 QObject* parent = 0L);
71
75 virtual ~KBufferedSocket();
76
80 virtual void setSocketDevice(KSocketDevice* device);
81
82protected:
86 virtual bool setSocketOptions(int opts);
87
88public:
95 virtual void close();
96
100 virtual qint64 bytesAvailable() const;
101
105 virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
106
110 virtual void enableRead(bool enable);
111
115 virtual void enableWrite(bool enable);
116
120 void setInputBuffering(bool enable);
121
125 void setOutputBuffering(bool enable);
126
130 virtual qint64 bytesToWrite() const;
131
138 virtual void closeNow();
139
143 virtual bool canReadLine() const;
144
145 // KDE4: make virtual, add timeout to match the Qt4 signature
146 // and move to another class up the hierarchy
151 void waitForConnect();
152
153protected:
159 virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from);
160
166 virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from);
167
173 virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to);
174
178 virtual qint64 readLineData(char *data, qint64 maxSize);
179
183 virtual void stateChanging(SocketState newState);
184
185protected Q_SLOTS:
189 virtual void slotReadActivity();
190
194 virtual void slotWriteActivity();
195
196#if 0
197 // Already present in QIODevice
198Q_SIGNALS:
202 void bytesWritten(int bytes);
203#endif
204
205private:
206 KBufferedSocket(const KBufferedSocket&);
207 KBufferedSocket& operator=(const KBufferedSocket&);
208
209 KBufferedSocketPrivate* const d;
210};
211
212} // namespace KNetwork
213
214#endif
KNetwork::KBufferedSocket::peekData
virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from)
Peeks data from the socket.
Definition k3bufferedsocket.cpp:135
KNetwork::KBufferedSocket::setSocketDevice
virtual void setSocketDevice(KSocketDevice *device)
Be sure to catch new devices.
Definition k3bufferedsocket.cpp:69
KNetwork::KBufferedSocket::slotReadActivity
virtual void slotReadActivity()
Slot called when there's read activity.
Definition k3bufferedsocket.cpp:296
KNetwork::KBufferedSocket::slotWriteActivity
virtual void slotWriteActivity()
Slot called when there's write activity.
Definition k3bufferedsocket.cpp:343
KNetwork::KBufferedSocket::stateChanging
virtual void stateChanging(SocketState newState)
Catch connection to clear the buffers.
Definition k3bufferedsocket.cpp:212
KNetwork::KBufferedSocket::enableRead
virtual void enableRead(bool enable)
Catch changes.
Definition k3bufferedsocket.cpp:183
KNetwork::KBufferedSocket::writeData
virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress *to)
Writes data to the socket.
Definition k3bufferedsocket.cpp:151
KNetwork::KBufferedSocket::setInputBuffering
void setInputBuffering(bool enable)
Sets the use of input buffering.
Definition k3bufferedsocket.cpp:230
KNetwork::KBufferedSocket::readData
virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from)
Reads data from a socket.
Definition k3bufferedsocket.cpp:119
KNetwork::KBufferedSocket::closeNow
virtual void closeNow()
Closes the socket and discards any output data that had been buffered with writeData() but that had n...
Definition k3bufferedsocket.cpp:266
KNetwork::KBufferedSocket::bytesAvailable
virtual qint64 bytesAvailable() const
Make use of the buffers.
Definition k3bufferedsocket.cpp:99
KNetwork::KBufferedSocket::enableWrite
virtual void enableWrite(bool enable)
Catch changes.
Definition k3bufferedsocket.cpp:200
KNetwork::KBufferedSocket::waitForMore
virtual qint64 waitForMore(int msecs, bool *timeout=0L)
Make use of buffers.
Definition k3bufferedsocket.cpp:107
KNetwork::KBufferedSocket::close
virtual void close()
Closes the socket for new data, but allow data that had been buffered for output with writeData() to ...
Definition k3bufferedsocket.cpp:85
KNetwork::KBufferedSocket::waitForConnect
void waitForConnect()
Blocks until the connection is either established, or completely failed.
Definition k3bufferedsocket.cpp:286
KNetwork::KBufferedSocket::setSocketOptions
virtual bool setSocketOptions(int opts)
Buffered sockets can only operate in non-blocking mode.
Definition k3bufferedsocket.cpp:76
KNetwork::KBufferedSocket::setOutputBuffering
void setOutputBuffering(bool enable)
Sets the use of output buffering.
Definition k3bufferedsocket.cpp:244
KNetwork::KBufferedSocket::bytesToWrite
virtual qint64 bytesToWrite() const
Returns the length of the output buffer.
Definition k3bufferedsocket.cpp:258
KNetwork::KBufferedSocket::canReadLine
virtual bool canReadLine() const
Returns true if a line can be read with readLine()
Definition k3bufferedsocket.cpp:273
KNetwork::KBufferedSocket::readLineData
virtual qint64 readLineData(char *data, qint64 maxSize)
Improve the readLine performance.
Definition k3bufferedsocket.cpp:281
KNetwork::KBufferedSocket::KBufferedSocket
KBufferedSocket(const QString &node=QString(), const QString &service=QString(), QObject *parent=0L)
Default constructor.
Definition k3bufferedsocket.cpp:52
KNetwork::KClientSocketBase::SocketState
SocketState
Socket states.
Definition k3clientsocketbase.h:73
KNetwork::KSocketAddress
A generic socket address.
Definition k3socketaddress.h:415
KNetwork::KSocketDevice
Low-level socket functionality.
Definition k3socketdevice.h:52
KNetwork::KStreamSocket::timeout
int timeout() const
Retrieves the timeout value (in milliseconds).
Definition k3streamsocket.cpp:75
KNetwork::KStreamSocket::KStreamSocket
KStreamSocket(const QString &node=QString(), const QString &service=QString(), QObject *parent=0L)
Default constructor.
Definition k3streamsocket.cpp:55
QObject
QString
qint64
k3streamsocket.h
kdecore_export.h
KNetwork
A namespace to store all networking-related (socket) classes.
Definition k3bufferedsocket.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal