Hi all,
I've been working for a while on a BSD server using KEIL MDK5 latest version 5.21a middleware. I'm using the multitask RTOS RTX in Round Robin mode. I'm using the common sequence task to handle a connection request on the socket:
1. socket 2. bind 3. listen 4. accept 5. send/receive 6. closesocket
My host application executes two kind of get command: the first one with a single connection request and a second one with a multiple connection requests (4 reqs in a single command). When it performs the second one, at the end of multiple send/receive session, I "close" the current socket (case 6), and I go to waiting for a new request connection (case 4). Now, in absence of new pending requests, the "accept" function doesn't block as I expected, but it reopens the previous one. So the next "receive" call fails and it leads to a kind infinite ping/pong behaviour.
I don't understand why the accept function doesn't block, waiting for new connection requests as it is expected using RTX RTOS.
Fabio
Between case #6 and case #4, is socket() called again?
Could another connection request already be queued?
Hi Zack,
No, the socket() function is not called between the cases. I'm not sure, i don't think because the host send a sequence of 4 consecutive requests, all of them are correctly processed by my server (I see all data i need). In any case, by supposing other pending requests, the "accept" function should validate only these latest ones, isn't? In my case it returns always a valid sock, it doesn't block more, and it starts a ping/pong between cases #6 n #4. In fact, my bsd server task remains in a "running state" forever.
Thank you for advance,