Search code examples
javascriptnode.jssocketstcposc

Node.js OSC Module send TCP


I am using the OSC module https://github.com/colinbdclark/osc.js but I am struggling to get it to work over TCP. I am unable to find any examples that use TCP, they are all based on UDP.

I have tried just creating a TCP client in node.js but still struggle to get the message encoded correctly into OSC format. I also believe it has to be encoded with SLIP as well?

I am very new at this so be gentle.

Would be amazing if someone could please point me in the right direction or provide an example about sending OSC messages via TCP in node.js

Thank you!

Wayde

PS. Happy to use osc-min module as well. As I know with that you can encode the message to an osc message and store in a var. But still can't get it to work over TCP .. works fine over UDP but my replys are larger than the what UDP can handle if that makes sense


Solution

  • I'm not very familiar with OSC, so I don't know about its internals, but osc.js does support TCP transport, like this:

    let server = new osc.TCPSocketPort({});
    
    server.open('127.0.0.1', 57121); // change to remote host/port
    
    server.on('ready', () => {
      console.log('ready');
      ...
    });
    

    According to the README:

    For stream-based protocols such as serial and TCP, osc.js will take care of SLIP framing for you.