root/OpenSceneGraph/trunk/examples/osgcluster/receiver.h @ 6941

Revision 6941, 1.9 kB (checked in by robert, 8 years ago)

From Martin Lavery and Robert Osfield, Updated examples to use a variation of the MIT License

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*-
2*
3*  OpenSceneGraph example, osgcluster.
4*
5*  Permission is hereby granted, free of charge, to any person obtaining a copy
6*  of this software and associated documentation files (the "Software"), to deal
7*  in the Software without restriction, including without limitation the rights
8*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*  copies of the Software, and to permit persons to whom the Software is
10*  furnished to do so, subject to the following conditions:
11*
12*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18*  THE SOFTWARE.
19*/
20
21#ifndef __RECEIVER_H
22#define __RECEIVER_H
23
24
25////////////////////////////////////////////////////////////
26// Receiver.h
27//
28// Class definition for the recipient of a broadcasted message
29//
30
31#if !defined(WIN32) || defined(__CYGWIN__)
32    #include <netinet/in.h>
33#endif
34
35class Receiver
36{
37    public :
38
39        Receiver();
40        ~Receiver();
41
42        // setBuffer defines the buffer into which the broadcasted
43        // message will be received.
44        void setBuffer( void *buffer, const unsigned int size );
45
46        // Define what port to listen and bind to
47        void setPort( const short port );
48
49        // Sync does a blocking wait to recieve next message
50        void sync( void );
51
52    private :
53        bool init( void );
54
55    private :
56#if defined (WIN32) && !defined(__CYGWIN__)
57        SOCKET _so;
58        SOCKADDR_IN saddr;
59#else
60        int _so;
61        struct sockaddr_in saddr;
62#endif
63    bool _initialized;
64    short _port;
65    void *_buffer;
66    unsigned int _buffer_size;
67};
68#endif 
Note: See TracBrowser for help on using the browser.