Note that there are some explanatory texts on larger screens.

plurals
  1. POC#/.NET Receiving UDP packets
    primarykey
    data
    text
    <p>I'm on OS X. I have a MIDI keyboard plugged in. In Audio MIDI Setup, I redirect MIDI events from the keyboard onto the network. it tells me it is using port 5004:</p> <p><img src="https://i.stack.imgur.com/VoQY6.png" alt="enter image description here"></p> <p>NOTE: Notice I have set 'who may connect me' to 'anyone', and in 'live routings' I have sent the MIDI keyboard routing INTO the network.</p> <p>Now from a C#/.NET script (within my Unity3D project), I attempt to listen to this port:</p> <pre><code>UdpClient udp; udp = new UdpClient( 5004 ) // &lt;-- SocketException: Address already in use System.Object myObj = null; udp.BeginReceive( new AsyncCallback( UDP_IncomingData ), myObj // udp_ep ); static void UDP_IncomingData( IAsyncResult ar ) { Debug.Log( "GotData" ); //Get the data from the response byte[] bResp = udp.EndReceive( ar, ref udp_ep ); //Convert the data to a string string sResponse = Encoding.UTF8.GetString( bResp ); //Display the string Console.WriteLine( sResponse ); //Close the UDP connection udp.Close( ); } </code></pre> <p>I can't understand this error message. Of course the port is in use; the MIDI keyboard should be broadcasting from this port.</p> <p>How do I listen to the broadcast?</p> <p>EDIT: I'm now thinking that I need to create the UDP client on a new unused port, and then connect to the port I'm interested in:</p> <pre><code>udp = new UdpClient( 0 ); // &lt;-- http://stackoverflow.com/questions/2456773/find-a-free-port udp.Connect( "192.168.0.13", 5004 ); </code></pre> <p>So now it doesn't generate any errors. But I press keys on the MIDI keyboard, and the received-data callback doesn't trigger. So I still don't know if I've got it right.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload