• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
  • network
tdesocketdevice.h
1/*
2 * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
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 TDESOCKETDEVICE_H
26#define TDESOCKETDEVICE_H
27
28#include <tqsocketnotifier.h>
29#include "tdesocketbase.h"
30
31namespace KNetwork {
32
33class TDESocketDevice;
34class TDESocketDeviceFactoryBase;
35
36class TDESocketDevicePrivate;
50class TDECORE_EXPORT TDESocketDevice: public KActiveSocketBase, public KPassiveSocketBase
51{
52public:
63 enum Capabilities
64 {
67 CanConnectString = 0x01,
68
71 CanBindString = 0x02,
72
75 CanNotBind = 0x04,
76
79 CanNotListen = 0x08,
80
84 CanMulticast = 0x10,
85
90 CanNotUseDatagrams = 0x20
91 };
92protected:
95 int m_sockfd;
96
97public:
104 explicit TDESocketDevice(const TDESocketBase* = 0L);
105
112 explicit TDESocketDevice(int fd);
113
117 virtual ~TDESocketDevice();
118
122 inline int socket() const
123 { return m_sockfd; }
124
134 virtual int capabilities() const
135 { return 0; }
136
140 virtual bool setSocketOptions(int opts);
141
145 virtual bool open(int mode);
146
152 virtual void close();
153
157 virtual void flush()
158 { }
159
164 virtual bool create(int family, int type, int protocol);
165
170 bool create(const KResolverEntry& address);
171
175 virtual bool bind(const KResolverEntry& address);
176
180 virtual bool listen(int backlog = 5); // 5 is arbitrary
181
185 virtual bool connect(const KResolverEntry& address);
186
191 virtual TDESocketDevice* accept();
192
196 virtual bool disconnect();
197
201 virtual TQ_LONG bytesAvailable() const;
202
209 virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
210
214 virtual TQ_LONG readBlock(char *data, TQ_ULONG maxlen);
215
219 virtual TQ_LONG readBlock(char *data, TQ_ULONG maxlen, TDESocketAddress& from);
220
224 virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
225
229 virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, TDESocketAddress& from);
230
234 virtual TQ_LONG writeBlock(const char *data, TQ_ULONG len);
235
239 virtual TQ_LONG writeBlock(const char *data, TQ_ULONG len, const TDESocketAddress& to);
240
244 virtual TDESocketAddress localAddress() const;
245
250 virtual TDESocketAddress peerAddress() const;
251
266 virtual TDESocketAddress externalAddress() const;
267
275 TQSocketNotifier* readNotifier() const;
276
283 TQSocketNotifier* writeNotifier() const;
284
291 TQSocketNotifier* exceptionNotifier() const;
292
311 virtual bool poll(bool* input, bool* output, bool* exception = 0L,
312 int timeout = -1, bool* timedout = 0L);
313
325 bool poll(int timeout = -1, bool* timedout = 0L);
326
327protected:
335 TDESocketDevice(bool, const TDESocketBase* parent = 0L);
336
352 virtual TQSocketNotifier* createNotifier(TQSocketNotifier::Type type) const;
353
354public:
365 static TDESocketDevice* createDefault(TDESocketBase* parent);
366
375 static TDESocketDevice* createDefault(TDESocketBase* parent, int capabilities);
376
383 static TDESocketDeviceFactoryBase* setDefaultImpl(TDESocketDeviceFactoryBase* factory);
384
389 static void addNewImpl(TDESocketDeviceFactoryBase* factory, int capabilities);
390
391private:
392 TDESocketDevice(const TDESocketDevice&);
393 TDESocketDevice& operator=(const TDESocketDevice&);
394
395 TDESocketDevicePrivate *d;
396};
397
402class TDESocketDeviceFactoryBase
403{
404public:
405 TDESocketDeviceFactoryBase() {}
406 virtual ~TDESocketDeviceFactoryBase() {}
407
408 virtual TDESocketDevice* create(TDESocketBase*) const = 0;
409};
410
415template<class Impl>
416class TDESocketDeviceFactory: public TDESocketDeviceFactoryBase
417{
418public:
419 TDESocketDeviceFactory() {}
420 virtual ~TDESocketDeviceFactory() {}
421
422 virtual TDESocketDevice* create(TDESocketBase* parent) const
423 { return new Impl(parent); }
424};
425
426} // namespaces
427
428#endif
KNetwork::KActiveSocketBase
Abstract class for active sockets.
Definition: tdesocketbase.h:444
KNetwork::KPassiveSocketBase
Abstract base class for passive sockets.
Definition: tdesocketbase.h:684
KNetwork::KResolverEntry
One resolution entry.
Definition: kresolver.h:67
KNetwork::TDESocketAddress
A generic socket address.
Definition: tdesocketaddress.h:424
KNetwork::TDESocketBase
Basic socket functionality.
Definition: tdesocketbase.h:98
KNetwork::TDESocketDeviceFactory
This class provides functionality for creating and registering socket implementations.
Definition: tdesocketdevice.h:417
KNetwork::TDESocketDevice
Low-level socket functionality.
Definition: tdesocketdevice.h:51
KNetwork::TDESocketDevice::flush
virtual void flush()
This call is not supported on sockets.
Definition: tdesocketdevice.h:157
KNetwork::TDESocketDevice::capabilities
virtual int capabilities() const
Returns the set of capabilities this socket class implements.
Definition: tdesocketdevice.h:134
KNetwork::TDESocketDevice::socket
int socket() const
Returns the file descriptor for this socket.
Definition: tdesocketdevice.h:122
KNetwork::TDESocketDevice::m_sockfd
int m_sockfd
The socket file descriptor.
Definition: tdesocketdevice.h:95
KNetwork::TDESocketDevice::Capabilities
Capabilities
Capabilities for the socket implementation.
Definition: tdesocketdevice.h:64
KNetwork
A namespace to store all networking-related (socket) classes.
Definition: kbufferedsocket.h:36
KStdAction::create
TDEAction * create(StdAction id, const char *name, const TQObject *recvr, const char *slot, TDEActionCollection *parent)

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.