create a tcp server in multiple-task similar with AT+CIPSERVER command

tangqingcai
Posts: 11
Joined: Thu Mar 23, 2017 3:05 am

create a tcp server in multiple-task similar with AT+CIPSERVER command

Postby tangqingcai » Tue May 14, 2019 3:49 am

platform:esp32
esp-idf version:v3.1
I want to write a test case in esp32,it is similar with AT+CIPSERVER command;
And i create two tasks, taskA and taskB .
taskA is used to control wifi connection and socket_listen=socket() ,bind(socket_listen), listen(socket_listen,5)
And then taskB is used to accept() client socket,because of accept() will block current task;
In taskA,i could close(socket_listen) and restart it;
Now i meet questions are:
1 every while() cycle in taskA,start server,bind,listen,close;the socket_listen will increase,
2 if my esp32 accept a socket client connect (which come from my android phone) ,then i close(socket_listen);
it will appear an error 113 in taskB;
then i restart socket_listen=socket() ,bind(socket_listen), listen(socket_listen,5) ;it does not appear error;
but i can not use my android phone to connect this socket_server again at this time;

I think my question is how does AT+CIPSERVER this command work?
And how to write a tcp server in multiple-task?

Who is online

Users browsing this forum: adam_esp, omborse__, WiFive and 19 guests