OpendTect-6_4  6.4
netserver.h
Go to the documentation of this file.
1 #ifndef netserver_h
2 #define netserver_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: March 2009
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "networkmod.h"
17 #include "callback.h"
18 #include "bufstring.h"
19 
20 mFDQtclass(QTcpSocket)
21 mFDQtclass(QTcpServer)
23 
24 
25 namespace Network
26 {
27 
28 class Socket;
29 
30 
31 mExpClass(Network) Server : public CallBacker
32 {
33 public:
34  Server();
35  ~Server();
36 
37  bool listen(const char* host,int port=0);
39  bool isListening() const;
40  int port() const;
41 
42  void close();
43  bool hasPendingConnections() const;
44  int write(int id,const char*);
46  int write(int id,const IOPar&);
47  void read(int id,BufferString&) const;
48  void read(int id,IOPar&) const;
49  const char* errorMsg() const;
50 
51  Socket* getSocket(int id);
52  const Socket* getSocket(int id) const;
53 
54  CNotifier<Server,int> newConnection;
55  CNotifier<Server,int> readyRead;
56 
57  mQtclass(QTcpSocket)* nextPendingConnection();
59 
60  bool waitForNewConnection(int msec);
63 
64  static const char* sKeyPort() { return "port"; }
65  static const char* sKeyTimeout() { return "timeout"; }
66  static const char* sKeyKillword() { return "kill"; }
67 
68 protected:
69 
70  void notifyNewConnection();
71  void readyReadCB(CallBacker*);
72  void disconnectCB(CallBacker*);
73 
74  mQtclass(QTcpServer)* qtcpserver_;
75  mQtclass(QTcpServerComm)* comm_;
76  mutable BufferString errmsg_;
77  ObjectSet<Socket> sockets_;
78  TypeSet<int> ids_;
79  ObjectSet<Socket> sockets2bdeleted_;
80 
81  friend class mQtclass(QTcpServerComm);
82 
83 };
84 
85 } // namespace Network
86 
87 
88 #endif
#define mExpClass(module)
Definition: commondefs.h:160
Definition: qtcpservercomm.h:25
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
#define mQtclass(cls)
Definition: commondefs.h:229
Definition: jobcommunic.h:24
mFDQtclass(QTcpSocket) mFDQtclass(QTcpServer) mFDQtclass(QTcpServerComm) namespace Network
Definition: netserver.h:20
Set of pointers to objects.
Definition: commontypes.h:32
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
BufferString errmsg_
Definition: horizontracker.h:119
Notifier with automatic capsule creation.
Definition: callback.h:395

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