COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
UDP_Sender.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef _UDP__SENDER_H_
9 #define _UDP__SENDER_H_
10 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 // CLASS UDP_Sender
12 //
13 // This class @@@
14 //
15 // Initial version: 2003-01-22 [we]
16 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 // (C) 2001 by VirCinity IT Consulting
18 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 // Changes:
20 //
21 #include "common.h"
22 #ifndef _WIN32
23 #include <netinet/in.h>
24 #else
25 #include <winsock2.h>
26 #endif
27 #ifndef NULL
28 #define NULL 0
29 #endif
30 
34 namespace covise
35 {
36 
38 {
39 public:
40  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41  // ++ Constructors / Destructor
42  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 
47  UDP_Sender(const char *hostname, int port,
48  const char *mcastif = NULL, int mcastttl = -1);
49 
53  UDP_Sender(const char *hostPort,
54  const char *mcastif = NULL, int mcastttl = -1);
55 
57  virtual ~UDP_Sender();
58 
59  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60  // ++ Operations
61  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
62 
63  // send a UDP packet: return #bytes sent, error ret=-1, error string set
64  int send(const void *buffer, int numsendBytes);
65 
66  // send \0-terminated string
67  int send(const char *string);
68 
69  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
70  // ++ Attribute request/set functions
71  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
72 
73  // return true if bad
74  bool isBad();
75 
76  // get error string of last error
77  const char *errorMessage();
78 
79 protected:
80  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81  // ++ Attributes
82  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83 
84  // address info to send to
85  struct sockaddr_in d_address;
86 
87  // error buffer: contains non-empty string if bad things happen
88  char d_error[1024];
89 
90  // Socket number
91  int d_socket;
92 
93 private:
94  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95  // ++ Internally used functions
96  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 
98  // Try to get IP, use no nameserver if dot-notation
99  unsigned long getIP(const char *hostname);
100 
101  // set up server data (used by constructors)
102  void setup(const char *hostname, int port,
103  const char *mcastif = NULL, int mcastttl = -1);
104 
105  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106  // ++ prevent auto-generated bit copy routines by default
107  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108 
110  UDP_Sender(const UDP_Sender &);
111 
113  UDP_Sender &operator=(const UDP_Sender &);
114 
116  UDP_Sender();
117 };
118 }
119 #endif
int d_socket
Definition: UDP_Sender.h:91
GLuint buffer
Definition: khronos-glext.h:6606
Definition: UDP_Sender.h:37
#define NULL
Definition: UDP_Sender.h:28
#define UTILEXPORT
Definition: coExport.h:182