/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include "Cluster.h" #include #include #include #include #if !defined (_WIN32) || defined(__CYGWIN__) #include #include #include #include #include #include #include #include #include #endif #include #if defined(__linux) #include #include #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) #include #include #elif defined(__sgi) #include #include #elif defined(__CYGWIN__) #include #elif defined (__GNU__) #include #elif defined(__sun) #include #include #elif defined (__APPLE__) #include #include #elif defined (_WIN32) #include #include #elif defined (__hpux) #include #else #error Teach me how to build on this system #endif #include #include #include #if defined (_WIN32) && !defined(__CYGWIN__) #include #else #include #include #include #include #include #include #include #endif #include #include #include const unsigned int CameraPacket::MAX_NUM_EVENTS = 10; const unsigned int CameraPacket::SWAP_BYTES_COMPARE = 0x12345678; void DataConverter::write(const osg::FrameStamp& fs) { osg::notify(osg::NOTICE)<<"writeFramestamp = "<sin_addr.s_addr); } else { saddr.sin_addr.s_addr = _address; } #endif #define _VERBOSE 1 #ifdef _VERBOSE unsigned char *ptr = (unsigned char *)&saddr.sin_addr.s_addr; printf( "Broadcast address : %u.%u.%u.%u\n", ptr[0], ptr[1], ptr[2], ptr[3] ); #endif _initialized = true; return _initialized; } void Broadcaster::setHost( const char *hostname ) { struct hostent *h; if( (h = gethostbyname( hostname )) == 0L ) { fprintf( stderr, "Broadcaster::setHost() - Cannot resolv an address for \"%s\".\n", hostname ); _address = 0; } else _address = *(( unsigned long *)h->h_addr); } void Broadcaster::setPort( const short port ) { _port = port; } void Broadcaster::setBuffer( void *buffer, const unsigned int size ) { _buffer = buffer; _buffer_size = size; } void Broadcaster::sync( void ) { if(!_initialized) init(); if( _buffer == 0L ) { fprintf( stderr, "Broadcaster::sync() - No buffer\n" ); return; } int result = 0; #if defined (_WIN32) && !defined(__CYGWIN__) unsigned int size = sizeof( SOCKADDR_IN ); result = sendto( _so, (const char *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size ); // int err = WSAGetLastError (); // int *dum = (int*) _buffer; #else unsigned int size = sizeof( struct sockaddr_in ); result = sendto( _so, (const void *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size ); #endif if (result) { OSG_NOTICE<<"Warning: sentTo(...) failed : errno="<