01-20-2023 08:29 AM
Hello everyone,
i want to creat a connection through TCPIP to write and read messages. i have different messages to write so i did the writing of each message using an event structure. Since i am new to labview there are some questions i have.
attached above is my TCPIP sender and server.
1) do i have to place the TCP Open Connection in the event structure for each button, that means openning a new connection every time i click on an event case (BT1,BT2,BT3) or is it preferable to open the connection only once as i did.i observed that when putting the tcp open connection in every event case (BT1,BT2,BT3) only the first event i click works the rest only sents me an error mail when clicked.
2) for every connection i open do i have to close after my message has been sent? forexample if i click on my BT1 do i have to close the connection. befrore reopenning when i have to send my second message in my BT2 event case?
i will be every happy to have answers to my questions 🙂
01-20-2023 09:00 AM - edited 01-20-2023 09:02 AM
1) Not if you open the connection before going into the while loop where the event structure is placed. That is, of course, given that you don't open connections to multiple different IPs.
2) No. It's not good to open and close connections every time as you need a local port to do that which isn't immediately released after close, but is held "in custody" by the system for some time so that, depending on the number of open/close actions going on per second, you might run out of local ports. The only solution would be to find a free local port and to use the same one over and over, but that's not the default in the TCP Open VI.
01-20-2023 09:04 AM
I haven't looked at your code, because (from your question) it sounds to me like you are making the classic mistake of worrying about "How" you code something before considering "What" you want to do.
I'm guessing that the "What" can be paraphrased as the following:
If the above scenario is accurate, and you know the "protocol" of the remote computer (and it is compatible with the model I'm proposing), you would do the following:
Bob Schor