COVISE Core
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
34namespace covise
35{
36
38{
39public:
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
79protected:
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
95#endif
96
97private:
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
115
118
121};
122}
123#endif
#define NULL
Definition: UDP_Sender.h:28
#define UTILEXPORT
Definition: coExport.h:206
GLuint buffer
Definition: khronos-glext.h:6606
list of all chemical elements
Definition: coConfig.h:27
Definition: UDP_Sender.h:38
UDP_Sender()
Default constructor: NOT IMPLEMENTED, checked by assert.
UDP_Sender(const UDP_Sender &)
Copy-Constructor: NOT IMPLEMENTED, checked by assert.
UDP_Sender & operator=(const UDP_Sender &)
Assignment operator: NOT IMPLEMENTED, checked by assert.
int d_socket
Definition: UDP_Sender.h:94