OpendTect  6.6
netserver.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Nanne Hemstra
8  Date: March 2009
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 
15 #include "networkcommon.h"
16 
17 mFDQtclass(QTcpSocket)
18 mFDQtclass(QTcpServer)
19 mFDQtclass(QLocalSocket)
20 mFDQtclass(QLocalServer)
22 
23 
24 namespace Network
25 {
26 
27 class Socket;
28 
31 public:
32  Server(bool islocal);
33  ~Server();
34 
35  bool listen(SpecAddr=Any,PortNr_Type port=0);
37  bool listen(const char* servernm,uiRetVal&);
38  bool isListening() const;
39  PortNr_Type port() const;
40  Authority authority() const;
41  bool isLocal() const { return qlocalserver_; }
42 
43  void close();
44  bool hasPendingConnections() const;
45  int write(int id,const char*);
47  int write(int id,const IOPar&);
48  void read(int id,BufferString&) const;
49  void read(int id,IOPar&) const;
50  const char* errorMsg() const;
51 
52  Socket* getSocket(int id);
53  const Socket* getSocket(int id) const;
54 
55  CNotifier<Server,int> newConnection;
56  CNotifier<Server,int> readyRead;
57 
58  mQtclass(QTcpSocket)* nextPendingConnection();
60  mQtclass(QLocalSocket)* nextPendingLocalConnection();
61 
62  bool waitForNewConnection(int msec);
65 
66  static const char* sKeyHostName() { return "hostname"; }
67  static const char* sKeyNoListen() { return "no-listen"; }
68  static const char* sKeyPort() { return "port"; }
69  static const char* sKeyTimeout() { return "timeout"; }
70  static const char* sKeyKillword() { return "kill"; }
71  static const char* sKeyLocal() { return "local"; }
72 
73 protected:
74 
75  void notifyNewConnection();
76  void readyReadCB(CallBacker*);
77  void disconnectCB(CallBacker*);
78 
79  mQtclass(QTcpServer)* qtcpserver_ = nullptr;
80  mQtclass(QLocalServer)* qlocalserver_ = nullptr;
81  mQtclass(QTcpServerComm)* comm_;
82  mutable BufferString errmsg_;
83  ObjectSet<Socket> sockets_;
84  TypeSet<int> ids_;
85  ObjectSet<Socket> sockets2bdeleted_;
86 
87  friend class mQtclass(QTcpServerComm);
88 
89 };
90 
91 } // namespace Network
ObjectSet
Set of pointers to objects.
Definition: commontypes.h:31
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
mFDQtclass
mFDQtclass(QTcpSocket) mFDQtclass(QTcpServer) mFDQtclass(QLocalSocket) mFDQtclass(QLocalServer) mFDQtclass(QTcpServerComm) namespace Network
Definition: netserver.h:17
Network
Definition: jobcommunic.h:22
uiRetVal
Definition: uistringset.h:105
sKey::Server
FixedString Server()
Definition: keystrs.h:137
CallBacker
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
mODTextTranslationClass
#define mODTextTranslationClass(clss)
Definition: uistring.h:40
Network::SpecAddr
SpecAddr
Definition: networkcommon.h:33
QTcpServerComm
Definition: qtcpservercomm.h:27
Network::Any
@ Any
Definition: networkcommon.h:33
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
networkcommon.h
mQtclass
#define mQtclass(cls)
Definition: commondefs.h:234
MPE::errmsg_
BufferString errmsg_
Definition: horizontracker.h:118
PortNr_Type
unsigned short PortNr_Type
Definition: commontypes.h:37
CNotifier
Notifier with automatic capsule creation.
Definition: notify.h:171
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
TypeSet< int >

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021