7 years, 6 months ago.

Udp Send Issue

Hi I'm trying to send data with udp using this library.But not send to data.So Udp "sendTo" function returns to -1. Udp sender code is below.How to resolve this problem.? Thanks for answer...

#include "mbed.h"
#include "EthernetInterface.h"

const char* ECHO_SERVER_ADDRESS = "";
const int ECHO_SERVER_PORT = 8999;
DigitalOut myled(LED1);

int main() {
    EthernetInterface eth;
    UDPSocket sock;
    Endpoint echo_server;
    echo_server.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
    char out_buffer[] = "Hello World";

    while(1) {
        int len=sock.sendTo(echo_server, out_buffer, sizeof(out_buffer));

Question relating to:

2 Answers

7 years, 4 months ago.

Thank you for reporting this problem. This should be fixed in Revision 26 of the EthernetInterface library.

Cheers, Emilio

Accepted Answer

I don't like to bother you, but there is a simple question regarding the Version/Release of the libraries: Is there any Revision-Index in the library/code (a list) everybody can check? I failed to find any advice in the MBED-articles. Probably I used wrong search-terms. Thank you and best regards. Georg

posted by Gesotec Gesotec 16 Feb 2013

Is there any Revision-Index in the library/code (a list) everybody can check?

Yes, every library has an "History" tab with a list of all the revisions. For example: http://mbed.org/users/mbed_official/code/EthernetInterface/shortlog

To update a library in an existing program, simply select the library folder and click on the “Update” button in the right “Library Details” panel.

HTH, Emilio

posted by Emilio Monti 18 Feb 2013

Dear Emilio, thank you for your support. I appreciate your help. You are doing a great job. The HardIP is working now.

In addition to our previous communication, I would like to get your opinion about the mbed UDP-Speed.

I have to get a 16bit word via SPI following by sending this value via UDP (16bit value every 6microseconds and faster).. Is it possible to manage this task using mbed? I've already deactivated the Checksum and set "set_blocking=false". Due to the above mentioned changes I've got a better performance but the mbed is freezing for timeouts below 5ms (SPI routine is fast enough and working; checked w/o ETH). There are some comments can be found on "mbed.org", but no one really describing the "diameter":) of the "bottleneck" (not to mention the solution).

Please find attached below the source I'm using . Best regards, Georg

  1. include "mbed.h"
  2. include "EthernetInterface.h"

const char* ECHO_SERVER_ADDRESS = ""; const int ECHO_SERVER_PORT = 60000;

int main() {

char u_buff[2]; u_buff[0]=0x41; u_buff[1]=0x42; EthernetInterface eth; eth.init("", "", ""); Use hard IP

eth.connect(); UDPSocket sock; sock.init(); sock.set_blocking(false);

Endpoint echo_server; echo_server.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);

while(1) { sock.sendTo(echo_server, u_buff, sizeof(u_buff)); wait_ms(1); } }

posted by Gesotec Gesotec 19 Apr 2013
7 years, 5 months ago.

Hi Gencer, I faced the same problem with 'sendTo' function. It always returns -1. I solved this problem by adding a DHCP. It seems like 'sendTo' function only works if you add DHCP in your system which is really surprising. I actually need to build my system without any DHCP. I hope Emilio Monti con help us with that.

Regards, Mahmud

Hi Mahmud, I faced the same issue you and Gencer described but I haven't found any solution in the articles. Is there something new regarding this problem?

Best regards, Georg

posted by Gesotec Gesotec 14 Feb 2013