Search code examples
c#localhostosc

C# udp socket doesn't receive data from localhost


I'm developing a C# application that talks to other C++ and C# applications using OSC formatted UDP data - To do that, I'm using the Bespoke OSC library.

Let's say my machine has the 192.168.1.190 address.

My C++ applications seem to be able to use 127.0.0.1 as an alias of 192.168.1.190.

My C# application(s), instead, can receive only from 127.0.0.1 if I opened the listener socket on 127.0.0.1 Or can receive only from 192.168.1.190 if I opened the listener socket on 192.168.1.190.

I mean: my C++ application receives without problems both from 127.0.0.1 and 192.168.1.190 if I open the listener socket either on 127.0.0.1 or 192.168.1.190.

Is it a behaviour of the Bespoke OSC library? Is it something I dont' know in C# sockets? Is it something I dont' know in sockets? Is it something I dont' know? Is it something YOU know?

Thanks for your attention

Orf Quarenghi


Solution

  • When you establish the IPEndPoint, you can specify IPAddress.Any which will listen for any IPs assigned to the machine.