LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP Write Restriction

Hi forum,

So I have created a TCP/IP multiple client connection based on the example that was provided in labview. However, I'm finding it difficult to "restrict" whoever writes to the server machine. I'm also completely lost on how I would go about this. So let's say I have 3 users connected through TCP/IP, I want to make sure that only user 1 can write and both 2 & 3 can only monitor. Any direction or suggestion would be very much appreciated.

0 Kudos
Message 1 of 4
(2,900 Views)

There are a lot of ways you could approach this. Do you have control over both the client and the server, or only the server? Do you trust the clients? If you develop the client software, and trust the users, then it might be as easy as sending a flag when a client connects that says "don't send any data." Of course this isn't secure, but it is simple. A better approach is to accept that you can't prevent the client from sending data, but you can ignore it. To do this you need to keep track of which connection sent the data, and determine whether you should act on it. Ideally, when a client sends data and the server disallows it, it should send some information back to the client indicating the reason for failure.

 

How will you determine which client is allowed to write - is it the first client to connect, or they need to enter a password, or they're connecting from a specific IP address, or something else?

 

If you're using the "Multiple Connections - Server" example, I would start by replacing the functional global variable with an actual queue (I think that example is so old that queues weren't available, or didn't support the right datatype, when it was written). Then replace the array of connection refnums with an array of clusters, where one element of the cluster is the connection refnum. Another element could be a boolean indicating whether or not that connection has permission to write to the server. Then, as you iterate through the connections, you'll be able to tell easily whether that particular connection is allowed to write. This image shows how you can use an array of clusters, and also uses a queue for passing new connections. One of the cluster elements is the time at which the server last received data from the client, and another is the buffer of data already received but not yet processed from that connection:

Message 2 of 4
(2,873 Views)

Nathand,

Wow. This is great! Thank you for this. I do have control over both server and client. I want the client that enters a password to be able to write and everyone else to just monitor. Is there any way that you can run me through what in the VI pasted here creates write connection? I didn't really understand the example and was only able to take from it using the highlight execution tool.

 

Thank you very much

0 Kudos
Message 3 of 4
(2,868 Views)

This VI doesn't do exacty what you need, it just demonstrates that you can put the connection reference into a cluster so that you can associate additional information with that specific connection. All TCP connections are bi-directional, there's no such thing as a read-only TCP connection. Any client will be able to send data to the server. You will need to write code that determines whether the server should accept that data, or ignore it.

0 Kudos
Message 4 of 4
(2,856 Views)