Also see:
c:
etos71\src reck
and
c:
etos71\lib\arm7\32b\gnu\libtcpip.a (This file contains a lot of Treck functions).
I’m asking this question here in a new topic because there is a lot of confusion about this topic. Some people say the stack is not re-entrant and also Digi Support says this. But this seems to be very strange, since the Teck documentation says the opposite.
I also have never heard of a any non-reentrant TCP/IP stacks. For example, see: http://tangentsoft.net/wskfaq/intermediate.html#threadsafety
“I don’t know of any implementations from Microsoft (or any other vendors) that are not thread safe.”
“The functions of send(), recv() select(), etc are fully reentrant. However, socket calls on the same socket from two different threads at the same time will lead to indeterminate behavior. To resolve this issue it is best to either do all your calls to a single socket within the same thread, or to mutex protect the thread.”
Only one question remains, though:
Is it safe to do select() in one thread (which blocks until data is ready to be read) and send() in another thread? Like this:
I’m using:
two threads
one TCP socket
one mutex to protect the socket
one queue that will be filled with data when something needs to be sent. (the tx_queue_send() calls are done by other threads).
TCP Receive thread:
while(true)
{
select(socket,readset) //wait for data to arrive on the socket
tx_mutex_get()
recv()
tx_mutex_put()
}
TCP Send thread:
while(true)
{
tx_queue_receive() //wait for data to be sent
tx_mutex_get()
send()
tx_mutex_put()
}
other threads:
tx_queue_send() //when some data needs to be sent