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 #ifdef WIN32
92  SOCKET d_socket;
93 #else
94  int d_socket;
95 #endif
96 
97 private:
98  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99  // ++ Internally used functions
100  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101 
102  // Try to get IP, use no nameserver if dot-notation
103  unsigned long getIP(const char *hostname);
104 
105  // set up server data (used by constructors)
106  void setup(const char *hostname, int port,
107  const char *mcastif = NULL, int mcastttl = -1);
108 
109  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110  // ++ prevent auto-generated bit copy routines by default
111  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 
114  UDP_Sender(const UDP_Sender &);
115 
117  UDP_Sender &operator=(const UDP_Sender &);
118 
120  UDP_Sender();
121 };
122 }
123 #endif
Definition: UDP_Sender.h:37
GLuint buffer
Definition: khronos-glext.h:6606
#define UTILEXPORT
Definition: coExport.h:194
#define NULL
Definition: UDP_Sender.h:28
int d_socket
Definition: UDP_Sender.h:94