change in call of socket (internally lwip_socket)

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

change in call of socket (internally lwip_socket)

Postby jumjum123 » Thu Dec 14, 2017 6:53 pm

In previous version call of socket(AF_INET,.....) to create a socket returned a number less than 32.
This behaviour seems to be "good practice" in other OS.
Actual version for ESP32 adds an offset (LWIP_SOCKET_OFFSET)
I could not find any information about this.
What is the reason for this change, for what can it be used ?
In our application we check the socket ID, which now causes an error.
Question is now, do we have to change our application, or is there any other option ?


ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: change in call of socket (internally lwip_socket)

Postby ESP_Angus » Thu Dec 14, 2017 10:22 pm

jumjum123 wrote:In previous version call of socket(AF_INET,.....) to create a socket returned a number less than 32.
This behaviour seems to be "good practice" in other OS.
Actual version for ESP32 adds an offset (LWIP_SOCKET_OFFSET)
I could not find any information about this.
What is the reason for this change, for what can it be used ?
This allows use of the same file descriptor values (and function calls) for both files and for sockets, previously it was tricky (and error prone) if you needed both in the same source file. This was a long-standing issue, discussed a bit here: https://github.com/espressif/esp-idf/issues/273
In our application we check the socket ID, which now causes an error.
Question is now, do we have to change our application, or is there any other option ?
What checks are you making? The return value of socket() in BSD sockets (and in IDF, before and after this change) is -1 for an error, and the file descriptor (an int) otherwise. If you change your application to check this, it will work with both versions.

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: change in call of socket (internally lwip_socket)

Postby jumjum123 » Fri Dec 15, 2017 12:00 am

@ESP_Angus there is a chack in core file of our application,m checking of socket ID less than 32.
We could add an #ifdef, to change this for ESP32 only, but thats an ugly solution.
Anyway, I will discuss with Espruino guys
Its 1:00 am for me now, so have a good night :-)

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 102 guests