tomwalters@509: /* tomwalters@509: oscpack -- Open Sound Control packet manipulation library tomwalters@509: http://www.audiomulch.com/~rossb/oscpack tomwalters@509: tomwalters@509: Copyright (c) 2004-2005 Ross Bencina tomwalters@509: tomwalters@509: Permission is hereby granted, free of charge, to any person obtaining tomwalters@509: a copy of this software and associated documentation files tomwalters@509: (the "Software"), to deal in the Software without restriction, tomwalters@509: including without limitation the rights to use, copy, modify, merge, tomwalters@509: publish, distribute, sublicense, and/or sell copies of the Software, tomwalters@509: and to permit persons to whom the Software is furnished to do so, tomwalters@509: subject to the following conditions: tomwalters@509: tomwalters@509: The above copyright notice and this permission notice shall be tomwalters@509: included in all copies or substantial portions of the Software. tomwalters@509: tomwalters@509: Any person wishing to distribute modifications to the Software is tomwalters@509: requested to send the modifications to the original developer so that tomwalters@509: they can be incorporated into the canonical version. tomwalters@509: tomwalters@509: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, tomwalters@509: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF tomwalters@509: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. tomwalters@509: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR tomwalters@509: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF tomwalters@509: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION tomwalters@509: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tomwalters@509: */ tomwalters@509: tomwalters@509: /* tomwalters@509: OscDump prints incoming Osc packets. Unlike the Berkeley dumposc program tomwalters@509: OscDump uses a different printing format which indicates the type of each tomwalters@509: message argument. tomwalters@509: */ tomwalters@509: tomwalters@509: tomwalters@509: #include tomwalters@509: tomwalters@509: #include "osc/OscReceivedElements.h" tomwalters@509: #include "osc/OscPrintReceivedElements.h" tomwalters@509: tomwalters@509: #include "ip/UdpSocket.h" tomwalters@509: #include "ip/PacketListener.h" tomwalters@509: tomwalters@509: tomwalters@509: class OscDumpPacketListener : public PacketListener{ tomwalters@509: public: tomwalters@509: virtual void ProcessPacket( const char *data, int size, tomwalters@509: const IpEndpointName& remoteEndpoint ) tomwalters@509: { tomwalters@509: std::cout << osc::ReceivedPacket( data, size ); tomwalters@509: } tomwalters@509: }; tomwalters@509: tomwalters@509: int main(int argc, char* argv[]) tomwalters@509: { tomwalters@509: if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){ tomwalters@509: std::cout << "usage: OscDump [port]\n"; tomwalters@509: return 0; tomwalters@509: } tomwalters@509: tomwalters@509: int port = 7000; tomwalters@509: tomwalters@509: if( argc >= 2 ) tomwalters@509: port = atoi( argv[1] ); tomwalters@509: tomwalters@509: OscDumpPacketListener listener; tomwalters@509: UdpListeningReceiveSocket s( tomwalters@509: IpEndpointName( IpEndpointName::ANY_ADDRESS, port ), tomwalters@509: &listener ); tomwalters@509: tomwalters@509: std::cout << "listening for input on port " << port << "...\n"; tomwalters@509: std::cout << "press ctrl-c to end\n"; tomwalters@509: tomwalters@509: s.RunUntilSigInt(); tomwalters@509: tomwalters@509: std::cout << "finishing.\n"; tomwalters@509: tomwalters@509: return 0; tomwalters@509: } tomwalters@509: tomwalters@509: