title: How can I recieve data over UDP on embedded device
body: <p>currently I am working on a UDP-Client Script for a Mbed Project. I work with the B-L475E-IOT01A development board and want to recieve data from another network device.</p>
  <p>The sending side (on another device) works. I tested it with a python script on my computer.</p>
  <p>I have the following problem: I can establish conection to the network and I can initialize a UDP socket with the <code>open()</code> function.
  My problem is, that if I try to <code>bind()</code> the socket to either a port or a socket address I get the <code>nsapi_error_t</code> code <code>-3002</code>, which means &quot;unsopported functionality&quot;.
  Here is the code:</p>
  <pre><code>#include &quot;UDPSocket.h&quot;
  #include &quot;mbed.h&quot;
  
  const char SSID[] = &quot;&quot;;
  const char password[] = &quot;&quot;;
  const uint16_t Port = 37020;
  
  UDPSocket socket;
  WiFiInterface *wifi;
  BufferedSerial pc(USBTX, USBRX, 115200);
  
  int main() {
    pc.set_format(8, SerialBase::None, 1);
  
    wifi = WiFiInterface::get_default_instance();
    if (!wifi) {
      printf(&quot;ERROR: No WiFiInterface found.\n&quot;);
      return -1;
    }
  
    printf(&quot;\nConnecting to %s...\n&quot;, SSID);
    int ret = wifi-&gt;connect(SSID, password, NSAPI_SECURITY_WPA2);
    if (ret != 0) {
      printf(&quot;\nConnection error: %d\n&quot;, ret);
      return -1;
    }
  
    SocketAddress a;
    wifi-&gt;get_ip_address(&amp;a);
    printf(&quot;IP: %s\n&quot;, a.get_ip_address());
  
    int returnable = 1;
    while (returnable != 0) {
      returnable = socket.open(wifi);
      printf(&quot;%d\r\n&quot;, returnable);
      wait_us(500000);
    }
  
    returnable = 1;
    while (returnable != 0) {
      returnable = socket.bind(Port);
      printf(&quot;%d\r\n&quot;, returnable);
      wait_us(500000);
    }
  
    while (1) {
      char message[500];
      int n = socket.recv(&amp;message, sizeof(message));
      printf(&quot;%d\r\n&quot;, n);
      printf(&quot;%s&quot;, message);
      wait_us(100000);
    }
    wifi-&gt;disconnect();
  
    printf(&quot;\nDone\n&quot;);
  }
  </code></pre>
  <p>I deleted the wifi data for safaty reasons. Here is the output:</p>
  <pre><code>Connecting to ...
  IP: 192.168.178.25
  0
  -3002
  </code></pre>
  <p>My question is, why I cant bind my board to a specific port. Do you have any ideas?
  Thank you in advance.</p>