class library: PriorityQueue - implement removeValue, hide array
[supercollider.git] / external_libraries / oscpack / examples / OscDump.cpp
blob0caba5cf98d8409bfd45576b467ecaf19b89c386
1 /*
2 oscpack -- Open Sound Control packet manipulation library
3 http://www.audiomulch.com/~rossb/oscpack
5 Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files
9 (the "Software"), to deal in the Software without restriction,
10 including without limitation the rights to use, copy, modify, merge,
11 publish, distribute, sublicense, and/or sell copies of the Software,
12 and to permit persons to whom the Software is furnished to do so,
13 subject to the following conditions:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 Any person wishing to distribute modifications to the Software is
19 requested to send the modifications to the original developer so that
20 they can be incorporated into the canonical version.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 OscDump prints incoming Osc packets. Unlike the Berkeley dumposc program
33 OscDump uses a different printing format which indicates the type of each
34 message argument.
38 #include <iostream>
39 #include <cstring>
40 #include <cstdlib>
42 #include "osc/OscReceivedElements.h"
43 #include "osc/OscPrintReceivedElements.h"
45 #include "ip/UdpSocket.h"
46 #include "ip/PacketListener.h"
49 class OscDumpPacketListener : public PacketListener{
50 public:
51 virtual void ProcessPacket( const char *data, int size,
52 const IpEndpointName& remoteEndpoint )
54 std::cout << osc::ReceivedPacket( data, size );
58 int main(int argc, char* argv[])
60 if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){
61 std::cout << "usage: OscDump [port]\n";
62 return 0;
65 int port = 7000;
67 if( argc >= 2 )
68 port = atoi( argv[1] );
70 OscDumpPacketListener listener;
71 UdpListeningReceiveSocket s(
72 IpEndpointName( IpEndpointName::ANY_ADDRESS, port ),
73 &listener );
75 std::cout << "listening for input on port " << port << "...\n";
76 std::cout << "press ctrl-c to end\n";
78 s.RunUntilSigInt();
80 std::cout << "finishing.\n";
82 return 0;