Bug fixed in the Makefile.
[Faustine.git] / interpretor / faust-0.9.47mr3 / architecture / osclib / oscpack / examples / OscDump.cpp
1 /*
2 oscpack -- Open Sound Control packet manipulation library
3 http://www.audiomulch.com/~rossb/oscpack
4
5 Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
6
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:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
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.
21
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.
29 */
30
31 /*
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.
35 */
36
37
38 #include <string.h>
39 #include <stdlib.h>
40 #include <iostream>
41
42 #include "osc/OscReceivedElements.h"
43 #include "osc/OscPrintReceivedElements.h"
44
45 #include "ip/UdpSocket.h"
46 #include "ip/PacketListener.h"
47
48
49 class OscDumpPacketListener : public PacketListener{
50 public:
51 virtual void ProcessPacket( const char *data, int size,
52 const IpEndpointName& remoteEndpoint )
53 {
54 std::cout << osc::ReceivedPacket( data, size );
55 }
56 };
57
58 int main(int argc, char* argv[])
59 {
60 if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){
61 std::cout << "usage: OscDump [port]\n";
62 return 0;
63 }
64
65 int port = 7000;
66
67 if( argc >= 2 )
68 port = atoi( argv[1] );
69
70 OscDumpPacketListener listener;
71 UdpListeningReceiveSocket s(
72 IpEndpointName( IpEndpointName::ANY_ADDRESS, port ),
73 &listener );
74
75 std::cout << "listening for input on port " << port << "...\n";
76 std::cout << "press ctrl-c to end\n";
77
78 s.RunUntilSigInt();
79
80 std::cout << "finishing.\n";
81
82 return 0;
83 }
84
85