09-25-2017 12:45 AM - edited 09-25-2017 12:46 AM
Hi.
I`d like to send binary files from a PC to another one using TCP/IP server program.
The name of the file I want to send is the number from 0 ~ n and send from 0 to n every 10 msecs.
I attached the server VI and Wireshark analysis below.
Wireshark analysis showed the program send same 2 packet after made connection and then program close tcp connection after send 2 packets and reconnecting again.
What is the problem with my server program?
Could I have your help?
Thank you.
Solved! Go to Solution.
09-25-2017 03:41 AM
Well, This is what you're doing:
1) The loop on the left will bring one CPU to it's knees. At least put a wait in there. But an event structure with value change event does almost the same...
2) You're getting the size of the directory. Then in the loops build the file paths. Why not use List Folder to get a list of files in the directory? Save's you the hassle in the loop...
3) After waiting for a listener (client), you send the same package yourself twice.
4) Then you wait 100 ms for one byte from the client, and clear the error if it has timed out.
5) Then you close the connection yourself.
So, you wait for client, send the first file twice, and close the connection.
You describe this as the problem, but it is exactly what you've made. It does exactly what you describe, as expected. We can't get from what you made what you expect it to do.
If you only want to write the file once, delete the second write.
If you don't want to open\close between each file, put the wait for listener and close outside the for loop. You'd need to add the length of the files, or you'll have no way on the client to split those files...
09-25-2017 11:36 AM
One of the Bane of Programmers is that "My Code Does What I Tell It To Do, Not What I Want It To Do". I've been know to comment that "Looking at your code, I have no idea what you want to do, but I can certainly see how you are doing it, even if I don't understand it".
Here are some "relevant" and "irrelevant" pieces from your initial description:
So a "high-level view" might go something like this:
I recommend using LabVIEW's Network Streams for this task, as it takes some of the details/drudgery out of the picture.
Bob Schor