OSC multiple port bug

From CSWiki
Jump to: navigation, search

OSC bug report, dan trueman

if you try to receive messages on multiple ports, things will eventually crash.

these example scripts will crash fairly quickly when the ports are different, but won't when they are the same.

> chuck send.ck recv.ck

this is reproducible when recv is run on a separate machine, and also when another application is doing the sending and chuck is only receiving.

OSX 10.4.11 MacBook 1/83 GHz recent build from CVS


//send.ck

OscSend xmit1, xmit2;

xmit1.setHost ( "localhost", 6448 ); //if the ports are the same, this won't crash
xmit2.setHost ( "localhost", 6449 );

while (true)
{

	send_msg1(Std.rand2(0, 100));
	Std.rand2(1, 10)::ms => now;
	
	send_msg2(Std.rand2(0, 100));
	Std.rand2(1, 10)::ms => now;

}
	

fun void send_msg1(int outval)
{
		// start the message...

			xmit1.startMsg( "msg1", "i" );

			outval => xmit1.addInt;


}

fun void send_msg2(int outval)
{
		// start the message...

			xmit2.startMsg( "msg2", "i" );

			outval => xmit2.addInt;


}

//recv.ck
spork ~ receive_msg1();
spork ~ receive_msg2();

while (true) { 1::second => now; }

fun void receive_msg1()
{
    // create our OSC receiver
    OscRecv recv;

    6448 => recv.port;
    // start listening (launch thread)
    recv.listen();

    // create an address in the receiver, store in new variable
    recv.event( "msg1, i" ) @=> OscEvent oe;
    
    int msgInt;

	
    // infinite event loop
    while ( true )
    {
        // wait for event to arrive
        oe => now;
		
        // grab the next message from the queue. 
        while( oe.nextMsg() != 0 )
        {

            oe.getInt() => msgInt;  

            
            <<<"got msg 1: ", msgInt>>>;

        }
    }
}

fun void receive_msg2()
{
    // create our OSC receiver
    OscRecv recv;

    6449 => recv.port;
    // start listening (launch thread)
    recv.listen();

    // create an address in the receiver, store in new variable
    recv.event( "msg2, i" ) @=> OscEvent oe;
    
    int msgInt;

	
    // infinite event loop
    while ( true )
    {
        // wait for event to arrive
        oe => now;
		
        // grab the next message from the queue. 
        while( oe.nextMsg() != 0 )
        {

            oe.getInt() => msgInt;  

            
            <<<"got msg 2: ", msgInt>>>;

        }
    }
}