OpendTect  6.3
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 ________________________________________________________________________
10 
11 -*/
12 
13 
14 #include "networkmod.h"
15 #include "notify.h"
16 #include "bufstring.h"
17 
18 mFDQtclass(QTcpSocket)
19 mFDQtclass(QTcpServer)
21 
22 
23 namespace Network
24 {
25 
26 class Socket;
27 
28 
29 mExpClass(Network) Server : public CallBacker
30 {
31 public:
32  Server();
33  ~Server();
34 
35  bool listen(const char* host,int port=0);
37  bool isListening() const;
38  int port() const;
39 
40  void close();
41  bool hasPendingConnections() const;
42  int write(int id,const char*);
44  int write(int id,const IOPar&);
45  void read(int id,BufferString&) const;
46  void read(int id,IOPar&) const;
47  const char* errorMsg() const;
48 
49  Socket* getSocket(int id);
50  const Socket* getSocket(int id) const;
51 
52  CNotifier<Server,int> newConnection;
53  CNotifier<Server,int> readyRead;
54 
55  mQtclass(QTcpSocket)* nextPendingConnection();
57 
58  bool waitForNewConnection(int msec);
61 
62 protected:
63 
64  void notifyNewConnection();
65  void readyReadCB(CallBacker*);
66  void disconnectCB(CallBacker*);
67 
68  mQtclass(QTcpServer)* qtcpserver_;
69  mQtclass(QTcpServerComm)* comm_;
70  mutable BufferString errmsg_;
71  ObjectSet<Socket> sockets_;
72  TypeSet<int> ids_;
73  ObjectSet<Socket> sockets2bdeleted_;
74 
75  friend class mQtclass(QTcpServerComm);
76 
77 };
78 
79 } // namespace Network
#define mExpClass(module)
Definition: commondefs.h:157
Definition: qtcpservercomm.h:24
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
#define mQtclass(cls)
Definition: commondefs.h:232
Definition: jobcommunic.h:22
mFDQtclass(QTcpSocket) mFDQtclass(QTcpServer) mFDQtclass(QTcpServerComm) namespace Network
Definition: netserver.h:18
Set of pointers to objects.
Definition: commontypes.h:28
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
BufferString errmsg_
Definition: horizontracker.h:117
Notifier with automatic capsule creation.
Definition: notify.h:166

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