[En-Nut-Discussion] NutTcpAccept blocks the tread
urbi
Urban.Battaglia at ch.TRUMPF.com
Wed Oct 21 23:31:08 CEST 2009
Ethernut wrote:
>
>>Unfortunately Urban's request wasn't that specific: "...so I have to
>>spend for each connection his own thread." This would be true for
>>Berkeley/Posix sockets as well. Btw. dynamically creating threads on
>>incoming connections is shown in the current app/httpd sample.
>
>>Urban, can you please specify in more detail, what you are expecting?
>
Ok. I will try to explaine wath I want to have. I use only in one project an
operating sytem. On other projects I am programming with event driven state
machins. The synchronisation for these state machins is implemented in the
main-loop. In such systems It is importend to have non blocking functions.
In this project with ethernut the application is a simple gateway from some
ethernet connections to a serial connection (in both directions). So I have
to implement 5 different sockets, that are listining for a TCP/IP
connection, read a request from the Host, send the request forward to the
uart, waiting for an answer from uart and give it back to the socket. The
next request follows on an answer.
The Gateway has to handle the different concurrent requests from each
socket. So I have one thread that query each open soket for data in the read
buffer and control the concurrent requests.
So reading and writing to all opened socket I have realized in one thread.
In my actual application I use for each port one thread for oppening and
colsing the connection because the blocking function NutTcpAccept().
I would like to have a non blocking function NutTcpAccept() that gives me
back a socket when the connection is ready otherwise an Error. So I can
query sequently in one thread each port for an incomming connection and
handle this connection. In an other thread (in fact thats th main-loop) I am
handling sequently reading and writing the data from all sockets and the
uart.
Of corse there are other ways to handle the different sockets from the
gateway functions, but with one thread and a sequently handling I have a lot
of synchronisation problems solved.
Urban
--
View this message in context: http://www.nabble.com/NutTcpAccept-blocks-the-tread-tp25791815p26000609.html
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.
More information about the En-Nut-Discussion
mailing list