Posted on 2010-01-05
Although my profile says I'm an expert, I'm really not (not sure how I received that classification). I'm pretty much a newbie, having done some VB6 GPIB programming several years back. So, I'm learning, or re-learning what I've done before.
I have a need to send queries to a spectrum analyzer, and to receive responses back using TCIP and winsock. I've been somewhat successful, however occassionaly my little program hiccups, and because of the asynchronous nature of winsock, some of the returns are either overwritten or simply missed. That may be due to analyzer task overload or LAN congestion. The sequence goes something like this:
(-> indicates query from client to analyzer)
(<- indicates analyzer response to client)
What is the frequency? ->
<- The frequency is 1.12 GHz
What is the resolution bandwidth? ->
<- The resolution bandwidth is 100 kHz
What is the sweep? ->
<- The sweep is 893 ms
... and so on.
The issue is that I need to wait until I get a response from the analyzer before I send the next query. Otherwise the response data is overwritten or somehow missed. I have instituted a timing wait, but that seems somewhat clumbsy and if I create too long of a wait, the whole communication process just takes longer to complete.
So, my question is; is there a way to send a query, and as soon as the response is received, immediately send the next query? I didn't seem to find anything in winsock that would permit that. It seems that winsock was built to be asynchronous.