We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have written a small embedded TCP/IP server application but it needs to work lock-step: one query then one response.
My problem is that the client (not under my control) making the requests is running ahead and I don't have the resources to buffer-up an arbitrarily large number of queries.
When a query comes in to the server, it arrives in the tcp_callback function. Data is arriving before I've fully sent the response to the previous one.
How do I impose some flow control on incoming data so that I can do things lock-step ?
Richard, I have to admit that I never worked with TCP/IP in an embedded environment (that is going to change...). I can only offer you some help based on my experiences in a PC environment. the API 'recv' in windows environment
int recv( SOCKET s, char FAR *buf, int len, int flags );
offers the 'flags' parameter which can also be: MSG_PEEK, which peeks at the incoming data. The data is copied into the buffer but is not removed from the input queue. The function then returns the number of bytes currently pending to receive.
you can also create a blocking socket by using the 'ioctlsocket' API, FIONBIO command. this API also allows peeking at what the socket has in store, but I guess it is very platform/application specific. you may be able to use 'setsockopt' to setup different parameters. generally, if you can use built-in buffers of TCP/IP, your problem is solved.