1 year, 10 months ago.

socket not available for use


I am trying to send UDP packages from one Nucleo767ZI board to another. On receiving board I am getting -3005 error.

Does anybody have idea what can be wrong?

Nucleo receiver

#include "mbed.h"
#include "lwip-interface/EthernetInterface.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);

static const char*          mbedIP       = "";  //IP  
static const char*          mbedMask     = "";  // Mask
static const char*          mbedGateway  = "";    //Gateway

const int PORT = 50081;

EthernetInterface eth;

SocketAddress rd_addr;
UDPSocket rd_sock(&eth);

void receive()
     int bind = rd_sock.bind(PORT);

    char buffer[256];
    int ret = rd_sock.recvfrom(&rd_addr , buffer, sizeof(buffer));
    if(ret > 0){
    buffer[ret] = '\0';
    printf("Packet from \"%s\": %s\n", rd_addr.get_ip_address(), buffer);
    led3 = !led3;

    printf("error %d\n", ret);

int main() {

    Thread receiver;

    eth.set_network(mbedIP, mbedMask, mbedGateway);


    while (true)
        led1 = !led1;

Thank you,


I found what on mbed-os 5.5.4 UDP is not working. Program just keeps running after calling sendto() function or just stops on it if run it like a thread. Works on previous releases 5.5.3, 5.5.2

posted by Daniel Klioc 10 Aug 2017
Comment on this question

1 Answer

1 year, 10 months ago.

We recommend using the latest version of EthernetInterface that is inside mbed OS now. Check out this documentation for some examples.

This example is mbed-os. I found problem what if you use printf in receive() thread it gets stuck or always too late to read data. If I delete printf`s, it starts to work, but after some time hangs in waiting data. Can it be something related with time out in Thread class?

posted by Daniel Klioc 09 Aug 2017

To post an answer, please log in.