root/oscpack/tags/release_1_0_2/examples/SimpleSend.cpp

Revision 45, 0.8 kB (checked in by ross, 3 years ago)

added examples/SimpleSend.cpp

  • Property svn:eol-style set to native
Line 
1 /*
2     Simple example of sending an OSC message using oscpack.
3 */
4
5 #include "osc/OscOutboundPacketStream.h"
6 #include "ip/UdpSocket.h"
7
8
9 #define ADDRESS "127.0.0.1"
10 #define PORT 7000
11
12 #define OUTPUT_BUFFER_SIZE 1024
13
14 int main(int argc, char* argv[])
15 {
16     UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) );
17    
18     char buffer[OUTPUT_BUFFER_SIZE];
19     osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE );
20    
21     p << osc::BeginBundleImmediate
22         << osc::BeginMessage( "/test1" )
23             << true << 23 << (float)3.1415 << "hello" << osc::EndMessage
24         << osc::BeginMessage( "/test2" )
25             << true << 24 << (float)10.8 << "world" << osc::EndMessage
26         << osc::EndBundle;
27    
28     transmitSocket.Send( p.Data(), p.Size() );
29 }
30
Note: See TracBrowser for help on using the browser.