Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / external_libraries / oscpack / examples / SimpleSend.cpp
blobb54faa607b27c82d387893b1d6300c0e08c89a3f
1 /*
2 Simple example of sending an OSC message using oscpack.
3 */
5 #include "osc/OscOutboundPacketStream.h"
6 #include "ip/UdpSocket.h"
9 #define ADDRESS "127.0.0.1"
10 #define PORT 7000
12 #define OUTPUT_BUFFER_SIZE 1024
14 int main(int argc, char* argv[])
16 UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) );
18 char buffer[OUTPUT_BUFFER_SIZE];
19 osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE );
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;
28 transmitSocket.Send( p.Data(), p.Size() );