Changeset 5

Show
Ignore:
Timestamp:
08/25/05 14:57:43 (3 years ago)
Author:
ross
Message:

commiting most recent pre-svn oscpack version. Main change is new networking classes with new unified UdpSocket? class, support for listening to multiple sockets. New IpEndpointName? class for refering to endpoints by name, ip address etc.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oscpack/trunk/LICENSE

    r1 r5  
    11oscpack -- Open Sound Control packet manipulation library 
    2 http://www.audiomulch.com/~rossb/oscpack 
     2http://www.audiomulch.com/~rossb/code/oscpack 
    33 
    44Copyright (c) 2004 Ross Bencina <rossb@audiomulch.com> 
  • oscpack/trunk/Makefile

    r1 r5  
    1111ENDIANESS=OSC_HOST_LITTLE_ENDIAN 
    1212 
    13 SENDSOURCES = ./osc/OscSendTests.cpp ./osc/OscOutboundPacketStream.cpp ./osc/OscTypes.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpTransmitPort.cpp 
     13SENDSOURCES = ./osc/OscSendTests.cpp ./osc/OscOutboundPacketStream.cpp ./osc/OscTypes.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp ./ip/IpEndpointName.cpp 
    1414SENDOBJECTS = $(SENDSOURCES:.cpp=.o) 
    1515 
    16 RECEIVESOURCES = ./osc/OscReceiveTest.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpPacketListenerPort.cpp 
     16RECEIVESOURCES = ./osc/OscReceiveTest.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp 
    1717RECEIVEOBJECTS = $(RECEIVESOURCES:.cpp=.o) 
    1818 
    19 DUMPSOURCES = ./osc/OscDump.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpPacketListenerPort.cpp 
     19DUMPSOURCES = ./osc/OscDump.cpp ./osc/OscTypes.cpp ./osc/OscReceivedElements.cpp ./osc/OscPrintReceivedElements.cpp ./ip/posix/NetworkingUtils.cpp ./ip/posix/UdpSocket.cpp 
    2020DUMPOBJECTS = $(DUMPSOURCES:.cpp=.o) 
    2121 
     
    3333test : $(TESTOBJECTS) 
    3434  @if [ ! -d bin ] ; then mkdir bin ; fi 
    35   $(CXX) -o bin/$@ $+ $(LIBS)  
     35  $(CXX) -o bin/$(TEST) $+ $(LIBS)  
    3636send : $(SENDOBJECTS) 
    3737  @if [ ! -d bin ] ; then mkdir bin ; fi 
    38   $(CXX) -o bin/$@ $+ $(LIBS)  
     38  $(CXX) -o bin/$(SEND) $+ $(LIBS)  
    3939receive : $(RECEIVEOBJECTS) 
    4040  @if [ ! -d bin ] ; then mkdir bin ; fi 
    41   $(CXX) -o bin/$@ $+ $(LIBS)  
     41  $(CXX) -o bin/$(RECEIVE) $+ $(LIBS)  
    4242dump : $(DUMPOBJECTS) 
    4343  @if [ ! -d bin ] ; then mkdir bin ; fi 
    44   $(CXX) -o bin/$@ $+ $(LIBS)  
     44  $(CXX) -o bin/$(DUMP) $+ $(LIBS)  
    4545 
    4646clean: 
  • oscpack/trunk/README

    r1 r5  
    11oscpack -- Open Sound Control packet manipulation library 
    2 Copyright (c) 2004 Ross Bencina <rossb@audiomulch.com> 
     2http://www.audiomulch.com/~rossb/code/oscpack 
     3 
     4Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com> 
    35 
    46A simple C++ library for packing and unpacking OSC packets. 
     
    2527OscPrintRecievedElements -- iostream << operators for printing packet elements 
    2628OscOutboundPacket -- a class for packing messages into a packet 
     29OscPacketListener -- base class for listening to OSC packets on a UdpSocket 
    2730OscUnitTests -- unit test program for the OSC modules 
    2831OscDump -- a program that prints received OSC packets 
     
    4346to Merlijn Blaauw for reviewing the interface. 
    4447 
    45 Completed at the Music Technology Group, Audiovisual Institute, 
    46 University Pompeu Fabra, Barcelona, November 2004. 
     48Portions developed at the Music Technology Group, Audiovisual Institute, 
     49University Pompeu Fabra, Barcelona, November 2004 - June 2005. 
     50 
     51See the file LICENSE for information about distributing and using this code. 
     52 
     53 
  • oscpack/trunk/TODO

    r1 r5  
    11TODO: 
    22 
    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 
    516 
    617    - provide some kind of automatic endianness configuration (hopefully there 
  • oscpack/trunk/ip/NetworkingUtils.h

    r1 r5  
    22#define INCLUDED_NETWORKINGUTILS_H 
    33 
    4 void InitializeNetworking(); 
    5 void TerminateNetworking(); 
    64 
    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. 
     9class NetworkInitializer{ 
     10public: 
     11    NetworkInitializer(); 
     12    ~NetworkInitializer(); 
     13}; 
     14 
     15 
     16// return ip address of host name in host byte order 
    1017unsigned long GetHostByName( const char *name ); 
    1118 
     19 
    1220#endif /* INCLUDED_NETWORKINGUTILS_H */ 
  • oscpack/trunk/ip/posix/NetworkingUtils.cpp

    r1 r5  
    2929*/ 
    3030#include "NetworkingUtils.h" 
     31 
    3132#include <netdb.h> 
    3233#include <sys/socket.h> 
    3334#include <netinet/in.h> 
    3435#include <string.h> 
    35  
    36 void InitializeNetworking() 
    37 
    38 
     36#include <stdio.h> 
    3937 
    4038 
    41 void TerminateNetworking() 
    42 {  
    43 
     39 
     40NetworkInitializer::NetworkInitializer() {} 
     41 
     42NetworkInitializer::~NetworkInitializer() {} 
    4443 
    4544 
     
    5251        struct in_addr a; 
    5352        memcpy( &a, h->h_addr_list[0], h->h_length ); 
    54         result = a.s_addr
     53        result = ntohl(a.s_addr)
    5554    } 
    5655 
    5756    return result; 
    5857} 
    59  
  • oscpack/trunk/ip/win32/NetworkingUtils.cpp

    r1 r5  
    3232#include <winsock2.h>   // this must come first to prevent errors with MSVC7 
    3333#include <windows.h> 
     34#include <stdlib.h> 
     35#include <stdio.h> 
    3436 
    3537 
    36 void InitializeNetworking() 
     38static LONG initCount_ = 0; 
     39static bool winsockInitialized_ = false; 
     40 
     41NetworkInitializer::NetworkInitializer() 
    3742{ 
    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    } 
    4560} 
    4661 
    4762 
    48 void TerminateNetworking() 
     63NetworkInitializer::~NetworkInitializer() 
    4964{ 
    50   // clean up winsock 
    51   WSACleanup(); 
     65    if( InterlockedDecrement( &initCount_ ) == 0 ){ 
     66        if( winsockInitialized_ ){ 
     67            WSACleanup(); 
     68            winsockInitialized_ = false; 
     69        } 
     70    } 
    5271} 
    5372 
     
    5574unsigned long GetHostByName( const char *name ) 
    5675{ 
     76    NetworkInitializer networkInitializer; 
     77 
    5778    unsigned long result = 0; 
    5879 
     
    6182        struct in_addr a; 
    6283        memcpy( &a, h->h_addr_list[0], h->h_length ); 
    63         result = a.s_addr
     84        result = ntohl(a.s_addr)
    6485    } 
    6586 
    6687    return result; 
    6788} 
    68  
  • oscpack/trunk/make.MinGW32.bat

    r1 r5  
    77g++ osc\OscUnitTests.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp osc\OscPrintReceivedElements.cpp osc\OscOutboundPacketStream.cpp -Wall -I..\ip -lws2_32 -o bin\OscUnitTests.exe 
    88 
    9 g++ osc\OscDump.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp osc\OscPrintReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpPacketListenerPort.cpp -Wall -Iip -lws2_32 -o bin\OscDump.exe 
     9g++ 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 
    1010 
    11 g++ osc\OscSendTests.cpp osc\OscTypes.cpp osc\OscOutboundPacketStream.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpTransmitPort.cpp -Wall -Iip -lws2_32 -o bin\OscSendTests.exe 
     11g++ 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 
    1212 
    13 g++ osc\OscReceiveTest.cpp osc\OscTypes.cpp osc\OscReceivedElements.cpp ip\win32\NetworkingUtils.cpp ip\win32\UdpPacketListenerPort.cpp -Wall -Iip -lws2_32 -o bin\OscReceiveTest.exe 
     13g++ 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 
    1414 
    15 OscUnitTests.exe 
     15.\bin\OscUnitTests.exe 
  • oscpack/trunk/osc/OscDump.cpp

    r1 r5  
    4141#include "OscPrintReceivedElements.h" 
    4242 
    43 #include "NetworkingUtils.h" 
    44 #include "UdpPacketListenerPort.h" 
     43#include "UdpSocket.h" 
     44#include "PacketListener.h" 
    4545 
    4646 
    47 class OscPacketListener : public UdpPacketListener{ 
     47class OscDumpPacketListener : public PacketListener{ 
    4848public: 
    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
    5454}; 
    55  
    5655 
    5756int main(int argc, char* argv[]) 
     
    6261    } 
    6362 
    64     InitializeNetworking()
     63 int port = 7000
    6564 
    66     int port = 7000; 
     65  if( argc >= 2 ) 
     66    port = atoi( argv[1] ); 
    6767 
    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 ); 
    7072 
    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"
    7375 
    74     std::cout << "listening for input on port " << port << "...\n"
     76 mux.RunUntilSigInt()
    7577 
    76     std::cout << "press any key + return to end\n"; 
    77     char c; 
    78     std::cin >> c; 
     78  std::cout << "finishing.\n";   
    7979 
    80     delete listenerPort; 
    81  
    82     TerminateNetworking(); 
    83      
    8480    return 0; 
    8581} 
  • oscpack/trunk/osc/OscHostEndianness.h

    r1 r5  
    4343// then you don't have to edit this file. 
    4444 
    45 #elif defined(__WIN32__) 
     45#elif defined(__WIN32__) || defined(WIN32) 
    4646 
    4747// assume that __WIN32__ is only defined on little endian systems 
  • oscpack/trunk/osc/OscPrintReceivedElements.cpp

    r1 r5  
    116116                // strip trailing newline from string returned by ctime 
    117117                const char *timeString = std::ctime( &t ); 
    118                 int len = strlen( timeString ); 
     118                size_t len = strlen( timeString ); 
    119119                char *s = new char[ len + 1 ]; 
    120120                strcpy( s, timeString ); 
  • oscpack/trunk/osc/OscReceiveTest.cpp

    r1 r5  
    2828  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    2929*/ 
    30 #include "OscReceiveTest.h" 
    31  
    3230#include <string.h> 
    3331#include <iostream> 
     
    3533#include "OscReceivedElements.h" 
    3634 
    37 #include "NetworkingUtils.h" 
    38 #include "UdpPacketListenerPort.h" 
     35#include "UdpSocket.h" 
     36#include "OscPacketListener.h" 
    3937 
    4038 
    4139namespace osc{ 
    4240 
    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 ) 
     41class OscReceiveTestPacketListener : public OscPacketListener{ 
     42protected: 
     43 
     44    void ProcessMessage( const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint ) 
    5745    { 
    5846        // 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 
    6049        // purpose of this example is to illustrate and test different argument 
    6150        // parsing methods 
     
    227216                        << m.AddressPattern() << ": " << e.what() << "\n"; 
    228217        } 
    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    }     
    240219}; 
    241220 
    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  
    257221} // namespace osc 
    258222 
    259 #ifndef NO_OSC_TEST_MAIN 
    260223 
    261224int main(int argc, char* argv[]) 
     
    266229    } 
    267230 
    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 
    286248    return 0; 
    287249} 
    288250 
    289 #endif /* NO_OSC_TEST_MAIN */ 
    290  
  • oscpack/trunk/osc/OscReceivedElements.cpp

    r1 r5  
    4343static inline const char* FindStr4End( const char *p ) 
    4444{ 
    45     assert( ((int)p & 0x03L) == 0 ); 
     45    assert( (reinterpret_cast<int>(p) & 0x03L) == 0 ); 
    4646 
    4747    p += 3; 
     
    5858static inline const char* FindStr4End( const char *p, const char *end ) 
    5959{ 
    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 ); 
    6262 
    6363    if( p >= end ) 
     
    7979static inline const char* RoundUp4( const char *p ) 
    8080{ 
    81     return (const char*)((long)(p-1) & (~0x03L)) + 4; 
     81    return reinterpret_cast<const char*>(reinterpret_cast<long>(p-1) & (~0x03L)) + 4; 
    8282} 
    8383 
  • oscpack/trunk/osc/OscReceivedElements.h

    r1 r5  
    418418  const char *AddressPattern() const { return addressPattern_; } 
    419419 
    420   unsigned long ArgumentCount() const { return typeTagsEnd_ - typeTagsBegin_; } 
     420  unsigned long ArgumentCount() const { return static_cast<unsigned long>(typeTagsEnd_ - typeTagsBegin_); } 
    421421 
    422422    const char *TypeTags() const { return typeTagsBegin_; } 
  • oscpack/trunk/osc/OscSendTests.cpp

    r1 r5  
    3535#include "OscOutboundPacketStream.h" 
    3636 
    37 #include "NetworkingUtils.h" 
    38 #include "UdpTransmitPort.h" 
     37#include "UdpSocket.h" 
     38#include "IpEndpointName.h" 
    3939 
    4040#define IP_MTU_SIZE 1536 
     
    4242namespace osc{ 
    4343     
    44 void RunSendTests( unsigned long address, int port ) 
     44void RunSendTests( const IpEndpointName& host ) 
    4545{ 
    46     InitializeNetworking(); 
    47  
    4846    char buffer[IP_MTU_SIZE]; 
    49  
    50     UdpTransmitPort *transmitPort = new UdpTransmitPort( address, port ); 
    51  
    52              
    5347    osc::OutboundPacketStream p( buffer, IP_MTU_SIZE ); 
    54  
     48  UdpTransmitSocket socket( host ); 
    5549 
    5650    p.Clear(); 
    5751    p << osc::BeginMessage( "/test1" ) 
    5852            << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; 
    59     transmitPort->Send( p.Data(), p.Size() ); 
     53    socket.Send( p.Data(), p.Size() ); 
    6054 
    6155    // test1 message with too few arguments 
     
    6357    p << osc::BeginMessage( "/test1" ) 
    6458            << true << osc::EndMessage; 
    65     transmitPort->Send( p.Data(), p.Size() ); 
     59    socket.Send( p.Data(), p.Size() ); 
    6660 
    6761    // test1 message with too many arguments 
     
    6963    p << osc::BeginMessage( "/test1" ) 
    7064            << true << 23 << (float)3.1415 << "hello" << 42 << osc::EndMessage; 
    71     transmitPort->Send( p.Data(), p.Size() ); 
     65    socket.Send( p.Data(), p.Size() ); 
    7266 
    7367    // test1 message with wrong argument type 
     
    7569    p << osc::BeginMessage( "/test1" ) 
    7670            << true << 1.0 << (float)3.1415 << "hello" << osc::EndMessage; 
    77     transmitPort->Send( p.Data(), p.Size() ); 
     71    socket.Send( p.Data(), p.Size() ); 
    7872 
    7973    p.Clear(); 
    8074    p << osc::BeginMessage( "/test2" ) 
    8175            << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; 
    82     transmitPort->Send( p.Data(), p.Size() ); 
     76    socket.Send( p.Data(), p.Size() ); 
    8377 
    8478    // send four /test3 messages, each with a different type of argument 
     
    8680    p << osc::BeginMessage( "/test3" ) 
    8781            << true << osc::EndMessage; 
    88     transmitPort->Send( p.Data(), p.Size() ); 
     82    socket.Send( p.Data(), p.Size() ); 
    8983 
    9084    p.Clear(); 
    9185    p << osc::BeginMessage( "/test3" ) 
    9286            << 23 << osc::EndMessage; 
    93     transmitPort->Send( p.Data(), p.Size() ); 
     87    socket.Send( p.Data(), p.Size() ); 
    9488 
    9589    p.Clear(); 
    9690    p << osc::BeginMessage( "/test3" ) 
    9791            << (float)3.1415 << osc::EndMessage; 
    98     transmitPort->Send( p.Data(), p.Size() ); 
     92    socket.Send( p.Data(), p.Size() ); 
    9993 
    10094    p.Clear(); 
    10195    p << osc::BeginMessage( "/test3" ) 
    10296           << "hello" << osc::EndMessage; 
    103     transmitPort->Send( p.Data(), p.Size() ); 
     97    socket.Send( p.Data(), p.Size() ); 
    10498     
    10599 
     
    165159 
    166160    p << osc::EndBundle; 
    167     transmitPort->Send( p.Data(), p.Size() ); 
     161    socket.Send( p.Data(), p.Size() ); 
    168162 
    169163 
     
    182176    << osc::EndBundle; 
    183177 
    184     transmitPort->Send( p.Data(), p.Size() ); 
    185  
    186     delete transmitPort; 
    187  
    188     TerminateNetworking(); 
     178    socket.Send( p.Data(), p.Size() ); 
    189179} 
    190180 
     
    200190    } 
    201191 
    202     InitializeNetworking(); 
    203  
    204192    char *hostName = "localhost"; 
    205193    int port = 7000; 
     
    211199        port = atoi( argv[2] ); 
    212200 
    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 ); 
    225211} 
    226212 
  • oscpack/trunk/osc/OscUnitTests.cpp

    r1 r5  
    136136            int n = (i++)->AsInt32(); 
    137137            (void)n; 
    138         }catch( Exception& e ){ 
     138        }catch( Exception& ){ 
    139139            exceptionThrown = true; 
    140140        } 
     
    231231        try{ 
    232232            TEST2_PRINT( "/a_char\0,x\0\0\0\0\0A" ); // unknown type tag 'x' 
    233         }catch( Exception& e ){ 
     233        }catch( Exception& ){ 
    234234            exceptionThrown = true; 
    235235        }