OpenCurves  0.9
realtimeudpconnection.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef REALTIMEUDPCONNECTION_H_
7 #define REALTIMEUDPCONNECTION_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include "realtimeconnection.h"
12 
13 #include <QHostAddress>
14 #include <vector>
15 
16 class QUdpSocket;
17 
21 {
22 public:
25 
28 
31  virtual QString name() const override;
32 
43  bool open(const QHostAddress &address, quint16 port);
44 
47  virtual bool isConnected() const override;
48 
50  virtual void disconnect() override;
51 
54  int send(const QByteArray &buffer) override;
55 
58  int read(QByteArray &buffer) override;
59 
60 private:
61  QUdpSocket *_socket;
62  QHostAddress _address;
63  quint16 _port;
64 };
65 
66 #endif // REALTIMEUDPCONNECTION_H_
~RealTimeUdpConnection()
Destructor, ensures disconnect() is called.
int read(QByteArray &buffer) override
Read data into the given buffer.
bool open(const QHostAddress &address, quint16 port)
Open a UDP connection to the indicated address and port.
virtual QString name() const override
The UDP address being used.
virtual bool isConnected() const override
Is the port open for communication?
RealTimeUdpConnection()
Create an unconnected UDP connection.
This is the base class for data source which provides data in real time.
Definition: realtimeconnection.h:16
virtual void disconnect() override
Disconnect if connected.
int send(const QByteArray &buffer) override
Send the given buffer to the source.
A RealTimeSource which reads from a UDP socket.
Definition: realtimeudpconnection.h:20