I am using data sockets to get data from a web site. I am using CVI7.0.
If I use the even model of the data sockets, I get the data from the web
site correctly but if I use the polling model, I get an eror, saying my
data type (when reading the data) should be LONG instead of CHAR*.
Here are the code samples:
First Event Model
void main(void)
{
int count;
char buf[8192];
DS_Open("hhtp://www.yahoo.com", DSConst_ReadBuffered, DSCallBack, buf,
&handle);
Wait(10.0) <- my func to call ProcessSystemEvents in a loop for 10secs.
DS_DiscardObjHandle(handle);
}
void CVICALLBACK DSCallBack(DSHandle dsHandle, int event, void
*callbackData)
{
int count;
char buf[32768];
switch (event) {
case DS_EVENT_DATAUPDATED:
DS_GetDa
taValue(dsHandle, CAVT_CSTRING, buf, 32768, &count, NULL);
printf("%s\n", buf);
break;
}
}
Now the polling mode***************************************
void main (void)
{
int count;
char buf[8192];
BOOL doneFlag;
double t0, t1;
DS_OpenEx("hhtp://www.yahoo.com", DSConst_ReadBuffered, NULL, NULL,
DSConst_PollingModel, 5000, &handle);
t0 = Timer();
t1 = Timer();
doneFlag = FALSE;
do {
retVal = DS_GetDataType(handle, &type, &length, NULL);
if (type == CAVT_LONG) {
printf("Type = %d\n", type);
} else if (type == CAVT_CSTRING) {
retVal = DS_GetDataValue(handle, CAVT_CSTRING, buf, 32768, &count, NULL);
if (retVal < 0) {
doneFlag = TRUE;
printf("Error in GetDataValue\n");
} else {
printf("%s\n", buf);
}
} else {
}
ProcessSystemEvents();
t1 = Timer();
} while ((doneFlag == FALSE) && ((t1-t0) < 10.0));
DS_DiscardObjHandle(handle);
}
In second case, I keep getting, type is LONG????
vishi