LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I detect the client IP connected with the server using Data Socket?

I'm making a client/server program using only the DataSocket Write and DataSocket Read VI's. I'm using the DS Write VI
in the server to write informations to localhost, and the DS Read VI in the client to read data in the server. It's necessary
to inform the server IP. But I need that server also read informations from many clients. For only one client, I used the DS
Write VI in the client and the DS Read VI in the server. The problem is: to use the DS Read VI in the server I always need
to especify the client IP before, and I only can read from one client. I need a way to use the Data Socket in order that the
server can detect automaticaly the client IP and to estabi
lish a communication. I tryed use the VI's inverse, using the DS Read
VI to read localhost and DS Write to transmit remotes informations, but doesn't function.
0 Kudos
Message 1 of 4
(3,386 Views)
I am attempting to perform the same function as you are and have not had much luck at it. I thought I would post a response to stimulate some discussion.

My initial, non elegant, solution to this problem was to write a small sub VI (see attached file) that runs on the 'DAQ/Server' computer. This sub VI searches for other clients by looping through a list of known computers on my LAN by building the source datasocket URL - ie. on the 1st iteration, URL = dstp://Computer1/book, where "Computer1" is the computer name on the LAN and "book" is the DataItem. The sub VI uses the 'DataSocket Read.VI' as the interogating mechanism to determine whether a client is connected to the DataSocket server and requesting/sending data. I set the "wait for updated value" property to "True" and set an arbitary wait interval in the "ms timeout" property.

My solution then RELIES on the 'DataSocket Read.VI' returning a FALSE value for the "timed out" property when it successfully finds the client and the DataItem on the network. If it does not find the DataItem (and by extension a matching client), it will timeout and return a TRUE value for this property.

In theory I thought this would work, however I have noticed a stange phenomenon, that I cannot explain, which causes this solution to fail. It seems that the DataSocket Read.VI ignores the 'DataItem' tag in the URL that it is passed and simply searches for the computer. For instance, if Computer1 has started a process on the DataSocket Server, and the DAQ/Server machine is searching for 'dstp://Computer1/xxzzyybook' the sub VI will indicate that it has found this item, despite the fact that this DataItem does NOT exist, and it will return an Empty/Null data value. It seems it does not matter what value I enter for the DataItem, the DataSocket Read.VI will always return a False value if ANY computer has started a DataSocket Server process. If Computer1 has NOT started a process on the DataSocket Server adn no other processes are running, the sub VI correctly returns that no client was found. My understanding of the DataSocket Read.VI is clearly incomplete. Does anyone understand why this phenomenon occurs?

Of course, there is a major time dependency introduced by this solution making it far from ideal. [The time delay is introduced since the DAQ/Server needs to search all networked computers to find active clients. I have noticed that if I start with a high "ms timeout" value (eg. 500ms) the sub VI finds the client, however if I reduced the "ms timeout" value to 100ms, then the Sub VI does not find any active clients.]

Like Anderson, I am in search of method to dynamically identify clients on the DataSocket server. Is there a means of interogatting the DS Server to determine the active clients? Help here would be greatly appreciated. Do we have to use TCP/IP VIs?

cheers,
Rob

p.s. to test my sub VI, start a VI on another machine that opens a DS Server process and publishes at least one data item to it.
0 Kudos
Message 2 of 4
(3,387 Views)

I am relatively new to the LabView environment.

I am able to view the connected computers through the DataSocket Server Diagnositcs. But i would like my VI to read that information programmatically.

Is that the same problem that you are having?

If you have any updates please reply.

Thank you.

Message 3 of 4
(3,122 Views)
cross-linked
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 4 of 4
(3,043 Views)