/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield * * This software is open source and may be redistributed and/or modified under * the terms of the GNU General Public License (GPL) version 2.0. * The full license is in LICENSE.txt file included with this distribution,. * * This software 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 * include LICENSE.txt for more details. */ #include "Cluster.h" #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__) #include #include #elif defined(__sgi) #include #include #elif defined(__CYGWIN__) #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; } #if defined (WIN32) && !defined(__CYGWIN__) unsigned int size = sizeof( SOCKADDR_IN ); 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 ); sendto( _so, (const void *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size ); #endif }