Changeset 5
- Timestamp:
- 08/25/05 14:57:43 (3 years ago)
- Files:
-
- oscpack/trunk/LICENSE (modified) (1 diff)
- oscpack/trunk/Makefile (modified) (2 diffs)
- oscpack/trunk/README (modified) (3 diffs)
- oscpack/trunk/TODO (modified) (1 diff)
- oscpack/trunk/ip/IpEndpointName.cpp (added)
- oscpack/trunk/ip/IpEndpointName.h (added)
- oscpack/trunk/ip/NetworkingUtils.h (modified) (1 diff)
- oscpack/trunk/ip/PacketListener.h (added)
- oscpack/trunk/ip/TimerListener.h (added)
- oscpack/trunk/ip/UdpPacketListenerPort.h (deleted)
- oscpack/trunk/ip/UdpSocket.h (added)
- oscpack/trunk/ip/UdpTransmitPort.h (deleted)
- oscpack/trunk/ip/posix/NetworkingUtils.cpp (modified) (2 diffs)
- oscpack/trunk/ip/posix/UdpPacketListenerPort.cpp (deleted)
- oscpack/trunk/ip/posix/UdpSocket.cpp (added)
- oscpack/trunk/ip/posix/UdpTransmitPort.cpp (deleted)
- oscpack/trunk/ip/win32/NetworkingUtils.cpp (modified) (3 diffs)
- oscpack/trunk/ip/win32/UdpPacketListenerPort.cpp (deleted)
- oscpack/trunk/ip/win32/UdpSocket.cpp (added)
- oscpack/trunk/ip/win32/UdpTransmitPort.cpp (deleted)
- oscpack/trunk/make.MinGW32.bat (modified) (1 diff)
- oscpack/trunk/osc/MessageMappingOscPacketListener.h (added)
- oscpack/trunk/osc/OscDump.cpp (modified) (2 diffs)
- oscpack/trunk/osc/OscHostEndianness.h (modified) (1 diff)
- oscpack/trunk/osc/OscPacketListener.h (added)
- oscpack/trunk/osc/OscPrintReceivedElements.cpp (modified) (1 diff)
- oscpack/trunk/osc/OscReceiveTest.cpp (modified) (4 diffs)
- oscpack/trunk/osc/OscReceiveTest.h (deleted)
- oscpack/trunk/osc/OscReceivedElements.cpp (modified) (3 diffs)
- oscpack/trunk/osc/OscReceivedElements.h (modified) (1 diff)
- oscpack/trunk/osc/OscSendTests.cpp (modified) (10 diffs)
- oscpack/trunk/osc/OscUnitTests.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
oscpack/trunk/LICENSE
r1 r5 1 1 oscpack -- Open Sound Control packet manipulation library 2 http://www.audiomulch.com/~rossb/ oscpack2 http://www.audiomulch.com/~rossb/code/oscpack 3 3 4 4 Copyright (c) 2004 Ross Bencina <rossb@audiomulch.com> oscpack/trunk/Makefile
r1 r5 11 11 ENDIANESS=OSC_HOST_LITTLE_ENDIAN 12 12 13 SENDSOURCES = ./osc/OscSendTests.cpp ./osc/OscOutboundPacketStream.cpp ./osc/OscTypes.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/Udp TransmitPort.cpp13 SENDSOURCES = ./osc/OscSendTests.cpp ./osc/OscOutboundPacketStream.cpp ./osc/OscTypes.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp ./ip/IpEndpointName.cpp 14 14 SENDOBJECTS = $(SENDSOURCES:.cpp=.o) 15 15 16 RECEIVESOURCES = ./osc/OscReceiveTest.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/Udp PacketListenerPort.cpp16 RECEIVESOURCES = ./osc/OscReceiveTest.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp 17 17 RECEIVEOBJECTS = $(RECEIVESOURCES:.cpp=.o) 18 18 19 DUMPSOURCES = ./osc/OscDump.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/Udp PacketListenerPort.cpp19 DUMPSOURCES = ./osc/OscDump.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp 20 20 DUMPOBJECTS = $(DUMPSOURCES:.cpp=.o) 21 21 … … 33 33 test : $(TESTOBJECTS) 34 34 @if [ ! -d bin ] ; then mkdir bin ; fi 35 $(CXX) -o bin/$ @$+ $(LIBS)35 $(CXX) -o bin/$(TEST) $+ $(LIBS) 36 36 send : $(SENDOBJECTS) 37 37 @if [ ! -d bin ] ; then mkdir bin ; fi 38 $(CXX) -o bin/$ @$+ $(LIBS)38 $(CXX) -o bin/$(SEND) $+ $(LIBS) 39 39 receive : $(RECEIVEOBJECTS) 40 40 @if [ ! -d bin ] ; then mkdir bin ; fi 41 $(CXX) -o bin/$ @$+ $(LIBS)41 $(CXX) -o bin/$(RECEIVE) $+ $(LIBS) 42 42 dump : $(DUMPOBJECTS) 43 43 @if [ ! -d bin ] ; then mkdir bin ; fi 44 $(CXX) -o bin/$ @$+ $(LIBS)44 $(CXX) -o bin/$(DUMP) $+ $(LIBS) 45 45 46 46 clean: oscpack/trunk/README
r1 r5 1 1 oscpack -- Open Sound Control packet manipulation library 2 Copyright (c) 2004 Ross Bencina <rossb@audiomulch.com> 2 http://www.audiomulch.com/~rossb/code/oscpack 3 4 Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com> 3 5 4 6 A simple C++ library for packing and unpacking OSC packets. … … 25 27 OscPrintRecievedElements -- iostream << operators for printing packet elements 26 28 OscOutboundPacket -- a class for packing messages into a packet 29 OscPacketListener -- base class for listening to OSC packets on a UdpSocket 27 30 OscUnitTests -- unit test program for the OSC modules 28 31 OscDump -- a program that prints received OSC packets … … 43 46 to Merlijn Blaauw for reviewing the interface. 44 47 45 Completed at the Music Technology Group, Audiovisual Institute, 46 University Pompeu Fabra, Barcelona, November 2004. 48 Portions developed at the Music Technology Group, Audiovisual Institute, 49 University Pompeu Fabra, Barcelona, November 2004 - June 2005. 50 51 See the file LICENSE for information about distributing and using this code. 52 53 oscpack/trunk/TODO
r1 r5 1 1 TODO: 2 2 3 - fix UDPPacketListenerPort to close the thread correctly (this applies 4 to both the posix and Win32 versions. 3 - consider adding ListenerThread class to support old seperate thread listener functionality, something like: 4 5 class UdpSocketListenerThread{ 6 public: 7 UdpSocketListenerThread( UdpSocket& socket, Listener *listener ); 8 UdpSocketListenerThread( UdpSocketReceiveMultiplexer *mux ); 9 ~UdpSocketListenerThread(); 10 11 void Run(); 12 void Stop(); 13 }; 14 15 5 16 6 17 - provide some kind of automatic endianness configuration (hopefully there oscpack/trunk/ip/NetworkingUtils.h
r1 r5 2 2 #define INCLUDED_NETWORKINGUTILS_H 3 3 4 void InitializeNetworking();5 void TerminateNetworking();6 4 7 #define PACK_IPV4_ADDRESS( a, b, c, d )\ 8 ( ((d) << 24) | ((c) << 16) | ((b) << 8) | (a) ) 9 5 // in general NetworkInitializer is only used internally, but if you're 6 // application creates multiple sockets from different threads at runtime you 7 // should instantiate one of these in main just to make sure the networking 8 // layer is initialized. 9 class NetworkInitializer{ 10 public: 11 NetworkInitializer(); 12 ~NetworkInitializer(); 13 }; 14 15 16 // return ip address of host name in host byte order 10 17 unsigned long GetHostByName( const char *name ); 11 18 19 12 20 #endif /* INCLUDED_NETWORKINGUTILS_H */ oscpack/trunk/ip/posix/NetworkingUtils.cpp
r1 r5 29 29 */ 30 30 #include "NetworkingUtils.h" 31 31 32 #include <netdb.h> 32 33 #include <sys/socket.h> 33 34 #include <netinet/in.h> 34 35 #include <string.h> 35 36 void InitializeNetworking() 37 { 38 } 36 #include <stdio.h> 39 37 40 38 41 void TerminateNetworking() 42 { 43 } 39 40 NetworkInitializer::NetworkInitializer() {} 41 42 NetworkInitializer::~NetworkInitializer() {} 44 43 45 44 … … 52 51 struct in_addr a; 53 52 memcpy( &a, h->h_addr_list[0], h->h_length ); 54 result = a.s_addr;53 result = ntohl(a.s_addr); 55 54 } 56 55 57 56 return result; 58 57 } 59 oscpack/trunk/ip/win32/NetworkingUtils.cpp
r1 r5 32 32 #include <winsock2.h> // this must come first to prevent errors with MSVC7 33 33 #include <windows.h> 34 #include <stdlib.h> 35 #include <stdio.h> 34 36 35 37 36 void InitializeNetworking() 38 static LONG initCount_ = 0; 39 static bool winsockInitialized_ = false; 40 41 NetworkInitializer::NetworkInitializer() 37 42 { 38 // initialize winsock 39 WSAData wsaData; 40 int nCode; 41 if ((nCode = WSAStartup(MAKEWORD(1, 1), &wsaData)) != 0) { 42 //std::cout << "WSAStartup() failed with error code " << nCode << "\n"; 43 return; 44 } 43 if( InterlockedIncrement( &initCount_ ) == 1 ){ 44 // there is a race condition here if one thread tries to access 45 // the library while another is still initializing it. 46 // i can't think of an easy way to fix it so i'm telling you here 47 // incase you need to init the library from two threads at once. 48 // this is why the header file advises to instantiate one of these 49 // in main() so that the initialization happens globally 50 51 // initialize winsock 52 WSAData wsaData; 53 int nCode = WSAStartup(MAKEWORD(1, 1), &wsaData); 54 if( nCode != 0 ){ 55 //std::cout << "WSAStartup() failed with error code " << nCode << "\n"; 56 }else{ 57 winsockInitialized_ = true; 58 } 59 } 45 60 } 46 61 47 62 48 void TerminateNetworking()63 NetworkInitializer::~NetworkInitializer() 49 64 { 50 // clean up winsock 51 WSACleanup(); 65 if( InterlockedDecrement( &initCount_ ) == 0 ){ 66 if( winsockInitialized_ ){ 67 WSACleanup(); 68 winsockInitialized_ = false; 69 } 70 } 52 71 } 53 72 … … 55 74 unsigned long GetHostByName( const char *name ) 56 75 { 76 NetworkInitializer networkInitializer; 77 57 78 unsigned long result = 0; 58 79 … … 61 82 struct in_addr a; 62 83 memcpy( &a, h->h_addr_list[0], h->h_length ); 63 result = a.s_addr;84 result = ntohl(a.s_addr); 64 85 } 65 86 66 87 return result; 67 88 } 68 oscpack/trunk/make.MinGW32.bat
r1 r5 7 7 g++ osc\OscUnitTests.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp osc\OscPrintReceivedElements.cpp osc\OscOutboundPacketStream.cpp -Wall -I..\ip -lws2_32 -o bin\OscUnitTests.exe 8 8 9 g++ osc\OscDump.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp osc\OscPrintReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\Udp PacketListenerPort.cpp -Wall -Iip -lws2_32-o bin\OscDump.exe9 g++ osc\OscDump.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp osc\OscPrintReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpSocket.cpp -Wall -Iip -lws2_32 -lwinmm -o bin\OscDump.exe 10 10 11 g++ osc\OscSendTests.cpp osc\OscTypes.cpp osc\OscOutboundPacketStream.cpp ip\win32\NetworkingUtils.cpp ip\win32\Udp TransmitPort.cpp -Wall -Iip -lws2_32-o bin\OscSendTests.exe11 g++ osc\OscSendTests.cpp osc\OscTypes.cpp osc\OscOutboundPacketStream.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpSocket.cpp ip\IpEndpointName.cpp -Wall -Iip -lws2_32 -lwinmm -o bin\OscSendTests.exe 12 12 13 g++ osc\OscReceiveTest.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\Udp PacketListenerPort.cpp -Wall -Iip -lws2_32-o bin\OscReceiveTest.exe13 g++ osc\OscReceiveTest.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpSocket.cpp -Wall -Iip -lws2_32 -lwinmm -o bin\OscReceiveTest.exe 14 14 15 OscUnitTests.exe15 .\bin\OscUnitTests.exe oscpack/trunk/osc/OscDump.cpp
r1 r5 41 41 #include "OscPrintReceivedElements.h" 42 42 43 #include " NetworkingUtils.h"44 #include " UdpPacketListenerPort.h"43 #include "UdpSocket.h" 44 #include "PacketListener.h" 45 45 46 46 47 class Osc PacketListener : public UdpPacketListener{47 class OscDumpPacketListener : public PacketListener{ 48 48 public: 49 virtual void ProcessPacket( const char *data, unsigned long size ) 50 { 51 osc::ReceivedPacket p( data, size ); 52 std::cout << p;53 }49 virtual void PacketReceived( const char *data, int size, 50 const IpEndpointName& remoteEndpoint ) 51 { 52 std::cout << osc::ReceivedPacket( data, size ); 53 } 54 54 }; 55 56 55 57 56 int main(int argc, char* argv[]) … … 62 61 } 63 62 64 InitializeNetworking();63 int port = 7000; 65 64 66 int port = 7000; 65 if( argc >= 2 ) 66 port = atoi( argv[1] ); 67 67 68 if( argc >= 2 ) 69 port = atoi( argv[1] ); 68 OscDumpPacketListener listener; 69 UdpReceiveSocket s( IpEndpointName( IpEndpointName::ANY_ADDRESS, port ) ); 70 SocketReceiveMultiplexer mux; 71 mux.AttachSocketListener( &s, &listener ); 70 72 71 OscPacketListener listener;72 UdpPacketListenerPort *listenerPort = new UdpPacketListenerPort( port, &listener );73 std::cout << "listening for input on port " << port << "...\n"; 74 std::cout << "press ctrl-c to end\n"; 73 75 74 std::cout << "listening for input on port " << port << "...\n";76 mux.RunUntilSigInt(); 75 77 76 std::cout << "press any key + return to end\n"; 77 char c; 78 std::cin >> c; 78 std::cout << "finishing.\n"; 79 79 80 delete listenerPort;81 82 TerminateNetworking();83 84 80 return 0; 85 81 } oscpack/trunk/osc/OscHostEndianness.h
r1 r5 43 43 // then you don't have to edit this file. 44 44 45 #elif defined(__WIN32__) 45 #elif defined(__WIN32__) || defined(WIN32) 46 46 47 47 // assume that __WIN32__ is only defined on little endian systems oscpack/trunk/osc/OscPrintReceivedElements.cpp
r1 r5 116 116 // strip trailing newline from string returned by ctime 117 117 const char *timeString = std::ctime( &t ); 118 int len = strlen( timeString );118 size_t len = strlen( timeString ); 119 119 char *s = new char[ len + 1 ]; 120 120 strcpy( s, timeString ); oscpack/trunk/osc/OscReceiveTest.cpp
r1 r5 28 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 29 */ 30 #include "OscReceiveTest.h"31 32 30 #include <string.h> 33 31 #include <iostream> … … 35 33 #include "OscReceivedElements.h" 36 34 37 #include " NetworkingUtils.h"38 #include " UdpPacketListenerPort.h"35 #include "UdpSocket.h" 36 #include "OscPacketListener.h" 39 37 40 38 41 39 namespace osc{ 42 40 43 class OscReceiveTestPacketListener : public UdpPacketListener{ 44 void ProcessBundle( const osc::ReceivedBundle& b ) 45 { 46 // ignore bundle time tag for this test 47 48 for( ReceivedBundle::const_iterator i = b.ElementsBegin(); i != b.ElementsEnd(); ++i ){ 49 if( i->IsBundle() ) 50 ProcessBundle( ReceivedBundle(*i) ); 51 else 52 ProcessMessage( ReceivedMessage(*i) ); 53 } 54 } 55 56 void ProcessMessage( const osc::ReceivedMessage& m ) 41 class OscReceiveTestPacketListener : public OscPacketListener{ 42 protected: 43 44 void ProcessMessage( const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint ) 57 45 { 58 46 // a more complex scheme involving std::map or some other method of 59 // processing address patterns could be used here. however, the main 47 // processing address patterns could be used here 48 // (see MessageMappingOscPacketListener.h for example). however, the main 60 49 // purpose of this example is to illustrate and test different argument 61 50 // parsing methods … … 227 216 << m.AddressPattern() << ": " << e.what() << "\n"; 228 217 } 229 } 230 231 public: 232 virtual void ProcessPacket( const char *data, unsigned long size ) 233 { 234 osc::ReceivedPacket p( data, size ); 235 if( p.IsBundle() ) 236 ProcessBundle( ReceivedBundle(p) ); 237 else 238 ProcessMessage( ReceivedMessage(p) ); 239 } 218 } 240 219 }; 241 220 242 243 static UdpPacketListenerPort *listenerPort_;244 OscReceiveTestPacketListener listener_;245 246 void StartReceiveTest( int port )247 {248 listenerPort_ = new UdpPacketListenerPort( port, &listener_ );249 }250 251 252 void EndReceiveTest()253 {254 delete listenerPort_;255 }256 257 221 } // namespace osc 258 222 259 #ifndef NO_OSC_TEST_MAIN260 223 261 224 int main(int argc, char* argv[]) … … 266 229 } 267 230 268 InitializeNetworking(); 269 270 int port = 7000; 271 272 if( argc >= 2 ) 273 port = atoi( argv[1] ); 274 275 osc::StartReceiveTest( port ); 276 std::cout << "listening for input on port " << port << "...\n"; 277 278 std::cout << "press any key + return to end\n"; 279 char c; 280 std::cin >> c; 281 282 osc::EndReceiveTest(); 283 284 TerminateNetworking(); 285 231 int port = 7000; 232 233 if( argc >= 2 ) 234 port = atoi( argv[1] ); 235 236 osc::OscReceiveTestPacketListener listener; 237 UdpReceiveSocket s( IpEndpointName( IpEndpointName::ANY_ADDRESS, port ) ); 238 SocketReceiveMultiplexer mux; 239 mux.AttachSocketListener( &s, &listener ); 240 241 std::cout << "listening for input on port " << port << "...\n"; 242 std::cout << "press ctrl-c to end\n"; 243 244 mux.RunUntilSigInt(); 245 246 std::cout << "finishing.\n"; 247 286 248 return 0; 287 249 } 288 250 289 #endif /* NO_OSC_TEST_MAIN */290 oscpack/trunk/osc/OscReceivedElements.cpp
r1 r5 43 43 static inline const char* FindStr4End( const char *p ) 44 44 { 45 assert( ( (int)p& 0x03L) == 0 );45 assert( (reinterpret_cast<int>(p) & 0x03L) == 0 ); 46 46 47 47 p += 3; … … 58 58 static inline const char* FindStr4End( const char *p, const char *end ) 59 59 { 60 assert( ( (int)p& 0x03L) == 0 );61 assert( ( (int)end& 0x03L) == 0 );60 assert( (reinterpret_cast<int>(p) & 0x03L) == 0 ); 61 assert( (reinterpret_cast<int>(end) & 0x03L) == 0 ); 62 62 63 63 if( p >= end ) … … 79 79 static inline const char* RoundUp4( const char *p ) 80 80 { 81 return (const char*)((long)(p-1) & (~0x03L)) + 4;81 return reinterpret_cast<const char*>(reinterpret_cast<long>(p-1) & (~0x03L)) + 4; 82 82 } 83 83 oscpack/trunk/osc/OscReceivedElements.h
r1 r5 418 418 const char *AddressPattern() const { return addressPattern_; } 419 419 420 unsigned long ArgumentCount() const { return typeTagsEnd_ - typeTagsBegin_; }420 unsigned long ArgumentCount() const { return static_cast<unsigned long>(typeTagsEnd_ - typeTagsBegin_); } 421 421 422 422 const char *TypeTags() const { return typeTagsBegin_; } oscpack/trunk/osc/OscSendTests.cpp
r1 r5 35 35 #include "OscOutboundPacketStream.h" 36 36 37 #include " NetworkingUtils.h"38 #include " UdpTransmitPort.h"37 #include "UdpSocket.h" 38 #include "IpEndpointName.h" 39 39 40 40 #define IP_MTU_SIZE 1536 … … 42 42 namespace osc{ 43 43 44 void RunSendTests( unsigned long address, int port )44 void RunSendTests( const IpEndpointName& host ) 45 45 { 46 InitializeNetworking();47 48 46 char buffer[IP_MTU_SIZE]; 49 50 UdpTransmitPort *transmitPort = new UdpTransmitPort( address, port );51 52 53 47 osc::OutboundPacketStream p( buffer, IP_MTU_SIZE ); 54 48 UdpTransmitSocket socket( host ); 55 49 56 50 p.Clear(); 57 51 p << osc::BeginMessage( "/test1" ) 58 52 << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; 59 transmitPort->Send( p.Data(), p.Size() );53 socket.Send( p.Data(), p.Size() ); 60 54 61 55 // test1 message with too few arguments … … 63 57 p << osc::BeginMessage( "/test1" ) 64 58 << true << osc::EndMessage; 65 transmitPort->Send( p.Data(), p.Size() );59 socket.Send( p.Data(), p.Size() ); 66 60 67 61 // test1 message with too many arguments … … 69 63 p << osc::BeginMessage( "/test1" ) 70 64 << true << 23 << (float)3.1415 << "hello" << 42 << osc::EndMessage; 71 transmitPort->Send( p.Data(), p.Size() );65 socket.Send( p.Data(), p.Size() ); 72 66 73 67 // test1 message with wrong argument type … … 75 69 p << osc::BeginMessage( "/test1" ) 76 70 << true << 1.0 << (float)3.1415 << "hello" << osc::EndMessage; 77 transmitPort->Send( p.Data(), p.Size() );71 socket.Send( p.Data(), p.Size() ); 78 72 79 73 p.Clear(); 80 74 p << osc::BeginMessage( "/test2" ) 81 75 << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; 82 transmitPort->Send( p.Data(), p.Size() );76 socket.Send( p.Data(), p.Size() ); 83 77 84 78 // send four /test3 messages, each with a different type of argument … … 86 80 p << osc::BeginMessage( "/test3" ) 87 81 << true << osc::EndMessage; 88 transmitPort->Send( p.Data(), p.Size() );82 socket.Send( p.Data(), p.Size() ); 89 83 90 84 p.Clear(); 91 85 p << osc::BeginMessage( "/test3" ) 92 86 << 23 << osc::EndMessage; 93 transmitPort->Send( p.Data(), p.Size() );87 socket.Send( p.Data(), p.Size() ); 94 88 95 89 p.Clear(); 96 90 p << osc::BeginMessage( "/test3" ) 97 91 << (float)3.1415 << osc::EndMessage; 98 transmitPort->Send( p.Data(), p.Size() );92 socket.Send( p.Data(), p.Size() ); 99 93 100 94 p.Clear(); 101 95 p << osc::BeginMessage( "/test3" ) 102 96 << "hello" << osc::EndMessage; 103 transmitPort->Send( p.Data(), p.Size() );97 socket.Send( p.Data(), p.Size() ); 104 98 105 99 … … 165 159 166 160 p << osc::EndBundle; 167 transmitPort->Send( p.Data(), p.Size() );161 socket.Send( p.Data(), p.Size() ); 168 162 169 163 … … 182 176 << osc::EndBundle; 183 177 184 transmitPort->Send( p.Data(), p.Size() ); 185 186 delete transmitPort; 187 188 TerminateNetworking(); 178 socket.Send( p.Data(), p.Size() ); 189 179 } 190 180 … … 200 190 } 201 191 202 InitializeNetworking();203 204 192 char *hostName = "localhost"; 205 193 int port = 7000; … … 211 199 port = atoi( argv[2] ); 212 200 213 unsigned long hostAddress = GetHostByName( hostName ); 214 215 std::cout << "sending test messages to " << hostName << " (" 216 << (hostAddress & 0xFF) << '.' 217 << ((hostAddress>>8) & 0xFF) << '.' 218 << ((hostAddress>>16) & 0xFF) << '.' 219 << ((hostAddress>>24) & 0xFF) 220 << ") on port " << port << "...\n"; 221 222 osc::RunSendTests( hostAddress, port ); 223 224 TerminateNetworking(); 201 202 IpEndpointName host( hostName, port ); 203 204 char hostIpAddress[ IpEndpointName::ADDRESS_STRING_LENGTH ]; 205 host.AddressAsString( hostIpAddress ); 206 207 std::cout << "sending test messages to " << hostName 208 << " (" << hostIpAddress << ") on port " << port << "...\n"; 209 210 osc::RunSendTests( host ); 225 211 } 226 212 oscpack/trunk/osc/OscUnitTests.cpp
r1 r5 136 136 int n = (i++)->AsInt32(); 137 137 (void)n; 138 }catch( Exception& e){138 }catch( Exception& ){ 139 139 exceptionThrown = true; 140 140 } … … 231 231 try{ 232 232 TEST2_PRINT( "/a_char\0,x\0\0\0\0\0A" ); // unknown type tag 'x' 233 }catch( Exception& e){233 }catch( Exception& ){ 234 234 exceptionThrown = true; 235 235 }
