6 years, 7 months ago.

socket not available for use

Hello,

Getting error socket not available for use or Error -3005 from Networking Errors list when trying to bind port for receiving data from it. Using NucleoF767ZI and UDP Socket

Does anybody nows what does it mean?

Regards, Daniel

If somebody knows documentation about UDP socket or threads with more details( have checked mbed Documentation already) please share.

posted by Daniel Klioc 21 Sep 2017

2 Answers

6 years, 7 months ago.

This is a good resource - https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/communication/network_sockets/.

What type of connectivity are you using? Is there only one socket open? If there is more than one, it might be that you have used the maximum amount allowed in this driver.

Thank you Sarah for reply,

1.Can you explain what you meant by type of connectivity? Ethernet I guess . Sending UDP messages from first NucleoF767 to second NucleoF767.

2.One socket for receiving and another for sending, but sending is working. What is limit?

3.Problem is in socket configuration I think. I am trying to receive UDP messages from broadcast IP and bind to specific port.

CODE EXAMPLE: const int PORT = 1234; example

EthernetInterface eth;

Thread thread;

void Receive(){ UDPSocket sock; SocketAddres addr;

sock.open(&eth); sock.bind(port)

char buffer[256];

while(1){ recvfrom(&addr ,buffer, sizeof(buffer)); } }

int main(){

thread.start(Receive); }

Result: getting -3003 error(invalid configuration) on opening socket or -3004(not connected to a network) on binding to port functions.

Daniel

posted by Daniel Klioc 21 Sep 2017

Are both boards connected by ethernet to the same network? In your example, you have not connected the board to the network.

eth.connect() would accomplish that.

posted by Sarah Marsh 22 Sep 2017

Yes, both boards connected to network with eth.connect() in main.

posted by Daniel Klioc 26 Sep 2017

Can you please post the full code with proper formatting? You do it by surrounding your code with "<<code>>" "<</code>>"

posted by Sarah Marsh 26 Sep 2017

Should I do it in comment or main post message?

posted by Daniel Klioc 26 Sep 2017

The main message works.

posted by Sarah Marsh 26 Sep 2017
6 years, 1 month ago.

I think you are suppose to call init() of EthernetInterface ..which getIp from DHCP.....