KDELibs4Support

k3serversocket.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 KSERVERSOCKET_H
26 #define KSERVERSOCKET_H
27 
28 #include <QObject>
29 #include "k3socketbase.h"
30 #include "k3streamsocket.h"
31 
32 namespace KNetwork
33 {
34 
35 class KStreamSocket;
36 class KResolver;
37 class KResolverResults;
38 
39 class KServerSocketPrivate;
109 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KServerSocket: public QObject, public KPassiveSocketBase
110 {
111  Q_OBJECT
112 public:
122  KServerSocket(QObject *parent = nullptr);
123 
140  KDELIBS4SUPPORT_DEPRECATED explicit KServerSocket(const QString &service, QObject *parent = nullptr);
141 
159  KServerSocket(const QString &node, const QString &service,
160  QObject *parent = nullptr);
161 
168  ~KServerSocket();
169 
170 protected:
174  bool setSocketOptions(int opts) override;
175 
176 public:
185  KResolver &resolver() const;
186 
190  const KResolverResults &resolverResults() const;
191 
206  void setResolutionEnabled(bool enable);
207 
214  void setFamily(int families);
215 
229  void setAddress(const QString &service);
230 
246  void setAddress(const QString &node, const QString &service);
247 
255  void setTimeout(int msecs);
256 
274  virtual bool lookup();
275 
289  virtual bool bind(const QString &node, const QString &service);
290 
297  virtual bool bind(const QString &service);
298 
304  virtual bool bind();
305 
313  bool bind(const KResolverEntry &address) override;
314 
328  bool listen(int backlog = 5) override; // 5 is arbitrary
329 
333  void close() override;
334 
346  void setAcceptBuffered(bool enable);
347 
360  KStreamSocket *accept() override;
361 
365  KSocketAddress localAddress() const override;
366 
370  KSocketAddress externalAddress() const override;
371 
372 private Q_SLOTS:
373  void lookupFinishedSlot();
374 
375 Q_SIGNALS:
381  void gotError(int code);
382 
386  void hostFound();
387 
394  void bound(const KNetwork::KResolverEntry &local);
395 
400  void closed();
401 
407  void readyAccept();
408 
409 protected:
414  void copyError();
415 
416 private:
417  bool doBind();
418  bool doListen();
419 
420 private:
421  KServerSocket(const KServerSocket &);
422  KServerSocket &operator=(const KServerSocket &);
423 
424  KServerSocketPrivate *const d;
425 };
426 
427 } // namespace KNetwork
428 
429 #endif
Simple stream socket.
A server socket for accepting connections.
One resolution entry.
Definition: k3resolver.h:72
Name and service resolution class.
Definition: k3resolver.h:312
A generic socket address.
Name and service resolution results.
Definition: k3resolver.h:212
A namespace to store all networking-related (socket) classes.
Abstract base class for passive sockets.
Definition: k3socketbase.h:773
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 7 2020 22:56:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.