Is there a way to receive OSC over TCP, or indeed any TCP, in sclang? Making an outgoing connection seems fine and sending via NetAddr seems to work, but how can I open a connection to receive data via TCP? The language can talk to the server via TCP so it should be in there somewhere, but how do I get to it?
Hello @ludo,
There’s currently no way to accept TCP connections in sclang. Sclang can only be a TCP client, and in that case it can still receive OSC messages sent “back” by the TCP server.
There’s a PR pending review that adds TCP server functionality, but I’m not sure if there are any caveats or when it’s going to be reviewed.
I created a quark for making web-based guis in SC and I needed to accept TCP connections too… For that purpose I ended up creating a “bridge” in a 3rd-party language (first Python, later Node) which would forward messages to sclang over OSC. Not elegant, but it works…
Thank you for your reply. Do you mean that one can get OSC over TCP back from a TCP server, if sclang is a TCP Client?
Your solution is indeed what I am also considering, a little Node thing that starts takes care of the TCP and then sends OSC to sclang. But if the OSC over TCP thing works, then I could have a pure TCP server in Node that relays messages between different TCP clients, and not translate to UDP at all.
OK, thank you very much, this at least allows my extra Node code to be a bit cleaner and I achieve my original goal of communicating without UDP, even though I will need an extra non-sclang component to pull it off. Cheers!
I would ask the following question to check if I misunderstand OSC, TCP and UDP. Of course, this question might not be related to your project because it is based on my humble knowledge without knowing your project characteristics.
As far as I know, if I correctly remember, OSC over TCP could be problematic in further communications between the server and the client when the server does not successfully receive data. It occurs because TCP continuously checks if the data is sent without loss and resends it until the server has entirely received data. In the worst case, a loop may occur due to an undelivered message if the Wi-Fi connection is unstable. Thus, UDP is better than TCP in controlling synthesis in real-time, even though sometimes OSC messages may not be delivered.
My question is as follows:
Could you give me some cases where OSC over TCP is required rather than over UDP?