Hopefully this isn't too stupid of a question, but I was wondering if I create a TCP socket as a server, listening for connections, is there an ISR for a client connection?
I would like to have a high priority task listening for connections, blocked on a semaphore. The semaphore would give from ISR when a client attempts to connect, unblocking this task and allowing it to service the client.
Thanks!
Is an interrupt on client connection possible?
Re: Is an interrupt on client connection possible?
Hi jpan227,
What you probably want is "select", which is the standard BSD sockets way to wait for something to happen on a socket (or group of sockets).
Unfortunately all of the ESP-IDF examples which use select() use it with UDP sockets, not TCP. However if you google you should be able to find a lot of sample code (written for Linux or similar OSes) which can be easily adapted to work in ESP-IDF.
Angus
What you probably want is "select", which is the standard BSD sockets way to wait for something to happen on a socket (or group of sockets).
Unfortunately all of the ESP-IDF examples which use select() use it with UDP sockets, not TCP. However if you google you should be able to find a lot of sample code (written for Linux or similar OSes) which can be easily adapted to work in ESP-IDF.
Angus
Re: Is an interrupt on client connection possible?
Hi, thanks!
I will take a deeper look into how it works.
Off the top of your head, do you have an idea of how it can be used? It seems like I would still need to poll for select() right?
I will take a deeper look into how it works.
Off the top of your head, do you have an idea of how it can be used? It seems like I would still need to poll for select() right?
Re: Is an interrupt on client connection possible?
Sure, here's some basic demo code. Copy it over main/main.c in the idf-template repo to build it:jpan127 wrote:Hi, thanks!
I will take a deeper look into how it works.
Off the top of your head, do you have an idea of how it can be used?
https://gist.github.com/projectgus/9e62 ... cad4a155ba
This is mostly cribbed from the the Wikipedia BSD sockets server example. It will need some extending to (for example) support multiple concurrent connections, but BSD sockets programming is well documented.
No. select() allows you to suspend the task until one of the sockets you are waiting on is ready (or until an optional timeout expires).It seems like I would still need to poll for select() right?
Re: Is an interrupt on client connection possible?
Oh wow that is awesome. How does this interact with freertos? What if the task is the lowest priority? Does it work the same way as a semaphore?
Re: Is an interrupt on client connection possible?
Yes, internally select() is in fact blocking on a semaphore. The calling task's priority will determine if it preempts other tasks or not, when data is available.jpan127 wrote:Oh wow that is awesome. How does this interact with freertos? What if the task is the lowest priority? Does it work the same way as a semaphore?
Note that TCP/IP stack handling also happens in a task, so you should orient any priorities relative to the TCP/IP task priority (ESP_TASK_TCPIP_PRIO ie 18). TCP/IP task can migrate between the two cores.
Re: Is an interrupt on client connection possible?
Ah, thank you so much, you've been a lot of help!
Who is online
Users browsing this forum: esp32New956832 and 103 guests