LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to datasocket when not using localhost?

I am trying to use datasockets to talk between two machines on my LAN. The
machine running the datasocket server is called SERVER. I start up the
datasocket server and then run my application on the server which calls:

iRc = DS_Open ("dstp://SERVER/broadcaster", DSConst_ReadAutoUpdate,
FaxBroadcastUnit, NULL, &dshGateway);

Here is the callback FaxBroadcastUnit():

void CVICALLBACK FaxBroadcastUnit (DSHandle dsHandle, int event,
void *callbackData)

{
char szRecordNum[6],szResultCode[5],szCurrentRecno[6];

iRc = DS_GetAttrValue (dshGateway, "batchrecordnumber", CAVT_CSTRING,
szRecordNum, sizeof(szRecordNum), NULL, NULL);
if (iRc<0)
return;
iRc = DS_G
etAttrValue (dshGateway, "batchresultcode", CAVT_CSTRING,
szResultCode, sizeof(szResultCode), NULL, NULL);

iRc = DS_GetAttrValue (dshGateway, "currentrecordnumber", CAVT_CSTRING,
szCurrentRecno, sizeof(szCurrentRecno), NULL, NULL);
printf("%s, %s %s\n",szRecordNum,szResultCode,szCurrentRecno);
}

On the other machine called MEDIASERVER I run a program which includes the
following lines:

iRc = DS_Open ("dstp://SERVER/broadcaster", DSConst_Write, NULL,
NULL, &dshServer);

DS_SetAttrValue (dshServer, "batchrecordnumber", CAVT_CSTRING, "1", 0,0);
DS_SetAttrValue (dshServer, "batchresultcode", CAVT_CSTRING, " ", 0,0);
DS_SetAttrValue (dshServer, "currentrecordnumber", CAVT_CSTRING, "1", 0,0);
iRc = DS_Update (dshServer);

I thought that running DS_Update() would cause the callback
FaxBroadcastUnit() to be called, but it doesn't work. I took a look at the
datasocket server applet. The number of processes connected remains at 1,
while th
e number of packets increased from 3 to 9. What am I doing wrong????

-Rich Bernstein
0 Kudos
Message 1 of 2
(3,131 Views)
I may have figured out your problem. First open the datasocket server manager from the 'start' menu and make sure the computer that is writing to the datasocket server is included in the default writers. I think the default is only for the local computer.

Besides that, I copied your code into my programs (a writer and reader) and I couldn't get it to work. But I have gotton something similar to work before so looked more closely. Basically what it comes down to is that you can't write to a datasocket attribute without writing to the (regular) datasocket first. I don't quiet understand why but if you add a DS_SetDataValue(....) before your DS_SetAttrValue(....) code on the write side then DS_GetDataValue(...) before the DS_GetAttrValue(..) code on the read side it work
s!! Just add anything, a junk string if you have too. In my program I add it but don't use the string at all because I don't like that you can't name it like the attributes, the only way to refer to it is with the datasocket handle.

Now when I tested your code, I did it with my program so I didn't use your function names or datasocket handle names but that part of your code looked fine. I did use your URL though (with my computer name).

Hope this helped,

Hector
0 Kudos
Message 2 of 2
(3,131 Views)