root/OpenSceneGraph/trunk/examples/osgcluster/broadcaster.h
@
6941
| Revision 6941, 2.1 kB (checked in by robert, 6 years ago) | |
|---|---|
|
|
| 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 __BROADCASTER_H |
| 22 | #define __BROADCASTER_H |
| 23 | |
| 24 | //////////////////////////////////////////////////////////// |
| 25 | // Broadcaster.h |
| 26 | // |
| 27 | // Class definition for broadcasting a buffer to a LAN |
| 28 | // |
| 29 | |
| 30 | #if !defined(WIN32) || defined(__CYGWIN__) |
| 31 | #include <netinet/in.h> |
| 32 | #endif |
| 33 | |
| 34 | class Broadcaster |
| 35 | { |
| 36 | public : |
| 37 | |
| 38 | Broadcaster( void ); |
| 39 | ~Broadcaster( void ); |
| 40 | |
| 41 | // Set the broadcast port |
| 42 | void setPort( const short port ); |
| 43 | |
| 44 | // Set the buffer to be broadcast |
| 45 | void setBuffer( void *buffer, const unsigned int buffer_size ); |
| 46 | |
| 47 | // Set a recipient host. If this is used, the Broadcaster |
| 48 | // no longer broadcasts, but rather directs UDP packets at |
| 49 | // host. |
| 50 | void setHost( const char *hostname ); |
| 51 | |
| 52 | // Sync broadcasts the buffer |
| 53 | void sync( void ); |
| 54 | |
| 55 | private : |
| 56 | bool init( void ); |
| 57 | |
| 58 | private : |
| 59 | #if defined(WIN32) && !defined(__CYGWIN__) |
| 60 | SOCKET _so; |
| 61 | #else |
| 62 | int _so; |
| 63 | #endif |
| 64 | bool _initialized; |
| 65 | short _port; |
| 66 | void *_buffer; |
| 67 | unsigned int _buffer_size; |
| 68 | #if defined(WIN32) && !defined(__CYGWIN__) |
| 69 | SOCKADDR_IN saddr; |
| 70 | #else |
| 71 | struct sockaddr_in saddr; |
| 72 | #endif |
| 73 | unsigned long _address; |
| 74 | }; |
| 75 | #endif |
Note: See TracBrowser
for help on using the browser.
