Poor name: espconn_accept

User avatar
kolban
Posts: 131
Joined: Tue Jun 16, 2015 1:09 pm
Location: Fort Worth, Texas, USA

Poor name: espconn_accept

Postby kolban » Wed Sep 23, 2015 10:48 am

After some thought, I think I really don't like the name of the function called "espconn_accept". What this function does is cause the ESP8266 to start listening on a local port for new incoming requests. Essentially making the ESP8266 a server. When we study the sockets API, we find that the equivalent function call to achieve this task is called "listen". So my suggested/recommended new name for this function would be "espconn_listen".

So where then did the "accept" name come from? The answer is that in sockets API there is a partner function called "accept". When executed against a socket that has previously had "listen" called against it, what it does is block until a partner actually attempts to connect. In the ESP8266, there is no equivalent. Instead, after "espconn_accept" is called, the ESP8266 immediately starts listening and when a partner connects, we wake up in the connect callback. So ... is "espconn_accept" a sockets "listen()" call or a sockets "accept()" call? My mind says that it is MUCH closer to a "listen()" call.

Who is online

Users browsing this forum: No registered users and 5 guests