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

KDECore

  • kdecore
  • network
k3socketdevice.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 KSOCKETDEVICE_H
26#define KSOCKETDEVICE_H
27
28#include <QtCore/QSocketNotifier>
29#include "k3socketbase.h"
30
31namespace KNetwork {
32
33class KSocketDevice;
34class KSocketDeviceFactoryBase;
35
36class KSocketDevicePrivate;
51class KDECORE_EXPORT_DEPRECATED KSocketDevice: public KActiveSocketBase, public KPassiveSocketBase
52{
53public:
64 enum Capabilities
65 {
68 CanConnectString = 0x01,
69
72 CanBindString = 0x02,
73
76 CanNotBind = 0x04,
77
80 CanNotListen = 0x08,
81
85 CanMulticast = 0x10,
86
91 CanNotUseDatagrams = 0x20
92 };
93protected:
96 int m_sockfd;
97
98public:
105 explicit KSocketDevice(const KSocketBase* = 0L, QObject* objparent = 0L);
106
113 explicit KSocketDevice(int fd, OpenMode mode = ReadWrite);
114
118 KSocketDevice(QObject* parent);
119
123 virtual ~KSocketDevice();
124
128 int socket() const;
129
139 virtual int capabilities() const;
140
144 virtual bool setSocketOptions(int opts);
145
151 virtual void close();
152
156 virtual bool flush();
157
162 virtual bool create(int family, int type, int protocol);
163
168 bool create(const KResolverEntry& address);
169
173 virtual bool bind(const KResolverEntry& address);
174
178 virtual bool listen(int backlog = 5); // 5 is arbitrary
179
183 virtual bool connect(const KResolverEntry& address,
184 OpenMode mode = ReadWrite);
185
190 virtual KSocketDevice* accept();
191
195 virtual bool disconnect();
196
200 virtual qint64 bytesAvailable() const;
201
208 virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
209
213 virtual KSocketAddress localAddress() const;
214
219 virtual KSocketAddress peerAddress() const;
220
235 virtual KSocketAddress externalAddress() const;
236
244 QSocketNotifier* readNotifier() const;
245
252 QSocketNotifier* writeNotifier() const;
253
260 QSocketNotifier* exceptionNotifier() const;
261
265 virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
266
270 virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
271
275 virtual qint64 writeData(const char *data, qint64 len,
276 const KSocketAddress* to = 0L);
277
296 virtual bool poll(bool* input, bool* output, bool* exception = 0L,
297 int timeout = -1, bool* timedout = 0L);
298
310 bool poll(int timeout = -1, bool* timedout = 0L);
311
312protected:
320 explicit KSocketDevice(bool, const KSocketBase* parent = 0L);
321
337 virtual QSocketNotifier* createNotifier(QSocketNotifier::Type type) const;
338
339public:
350 static KSocketDevice* createDefault(KSocketBase* parent);
351
360 static KSocketDevice* createDefault(KSocketBase* parent, int capabilities);
361
368 static KSocketDeviceFactoryBase* setDefaultImpl(KSocketDeviceFactoryBase* factory);
369
374 static void addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities);
375
376private:
377 KSocketDevice(const KSocketDevice&);
378 KSocketDevice& operator=(const KSocketDevice&);
379
380 KSocketDevicePrivate* const d;
381};
382
387class KSocketDeviceFactoryBase
388{
389public:
390 KSocketDeviceFactoryBase() {}
391 virtual ~KSocketDeviceFactoryBase() {}
392
393 virtual KSocketDevice* create(KSocketBase*) const = 0;
394};
395
400template<class Impl>
401class KSocketDeviceFactory: public KSocketDeviceFactoryBase
402{
403public:
404 KSocketDeviceFactory() {}
405 virtual ~KSocketDeviceFactory() {}
406
411 virtual KSocketDevice* create(KSocketBase* parent) const
412 { return new Impl(parent); }
413};
414
415} // namespaces
416
417#endif
KNetwork::KActiveSocketBase
Abstract class for active sockets.
Definition: k3socketbase.h:462
KNetwork::KPassiveSocketBase
Abstract base class for passive sockets.
Definition: k3socketbase.h:775
KNetwork::KResolverEntry
One resolution entry.
Definition: k3resolver.h:69
KNetwork::KSocketAddress
A generic socket address.
Definition: k3socketaddress.h:415
KNetwork::KSocketBase
Basic socket functionality.
Definition: k3socketbase.h:86
KNetwork::KSocketDeviceFactoryBase
Definition: k3socketdevice.h:388
KNetwork::KSocketDeviceFactoryBase::KSocketDeviceFactoryBase
KSocketDeviceFactoryBase()
Definition: k3socketdevice.h:390
KNetwork::KSocketDeviceFactoryBase::~KSocketDeviceFactoryBase
virtual ~KSocketDeviceFactoryBase()
Definition: k3socketdevice.h:391
KNetwork::KSocketDeviceFactoryBase::create
virtual KSocketDevice * create(KSocketBase *) const =0
KNetwork::KSocketDeviceFactory
This class provides functionality for creating and registering socket implementations.
Definition: k3socketdevice.h:402
KNetwork::KSocketDeviceFactory::~KSocketDeviceFactory
virtual ~KSocketDeviceFactory()
Definition: k3socketdevice.h:405
KNetwork::KSocketDeviceFactory::KSocketDeviceFactory
KSocketDeviceFactory()
Definition: k3socketdevice.h:404
KNetwork::KSocketDeviceFactory::create
virtual KSocketDevice * create(KSocketBase *parent) const
Create the socket implementation.
Definition: k3socketdevice.h:411
KNetwork::KSocketDevice
Low-level socket functionality.
Definition: k3socketdevice.h:52
KNetwork::KSocketDevice::Capabilities
Capabilities
Capabilities for the socket implementation.
Definition: k3socketdevice.h:65
KNetwork::KSocketDevice::m_sockfd
int m_sockfd
The socket file descriptor.
Definition: k3socketdevice.h:96
QObject
qint64
output
void output(QList< Action > actions, QHash< QString, QString > domain)
Definition: fake/kauth-policy-gen-polkit.cpp:41
k3socketbase.h
timeout
int timeout
Definition: kkernel_mac.cpp:46
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-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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
  • Modules
  • 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