LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I transfer a file through a TCP connection?

In each iteration of the loop, have two TCP Writes.  The first sends the size of the .jpg you're transmitting, and the second transmits the .jpb.
 
Because the file size data will always be 4 bytes, your TCP Read loop knows to read the first transmission as 4 bytes, and to decode that transmission as an I32 to use as the size of the second TCP Read.
 




Message Edited by JeffOverton on 06-11-2008 02:32 PM
0 Kudos
Message 21 of 38
(1,731 Views)
thanks!!
0 Kudos
Message 22 of 38
(1,724 Views)
OK, I set up my vi to transfer info following your example in message 21. I have a couple questions though. How do I put in the little blue box above between the string length function and the type cast function that says I32? I don't know if it matters but I am using labVIEW 8.5, on linux.

Also, what I just asked might solve my problem, but if not here it is:
when I run my passive & active VIs, I get this error when the passive vi hits the read binary file function:

               " Error 116 occured at Read from Binary File in TCP_send_pic_single2.vi
                                        Possible Reason(s):
                                        LabVIEW: Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data.  "

The file I'm trying to send is a .JPG file, and the file itself is fine, so I don't know how to fix the unexpected or truncated part.

Any help/ideas would be awesome, thanks!!Smiley Tongue
0 Kudos
Message 23 of 38
(1,691 Views)
Forgot to say that if I click continue, it sends four bytes to the folder I specified, with the name I specified. It does this whether or not I send the length of the file first; it sends the 4 bytes regardless.

thankies
0 Kudos
Message 24 of 38
(1,689 Views)
Hi ekarl,
you can also send it like shown in the picture or you connect both send vi´s with the error cluster to set the correct execution order.

Mike
0 Kudos
Message 25 of 38
(1,687 Views)
Hi MikeS81,
I appreciate your reply so much!! About the picture you sent, I'm not sure if I could make it work because the part that says 'your data here' would come from the read from binary file function (as I understand it, but I could be way off), and what I'm seeing is that the function is not actually producing a valid string of data when it reads the .jpg file. Do you have any idea why that might be happening, or if there is another way to send the file across TCP? I'm not sure I understand the other option about error clusters.

Thank You!
0 Kudos
Message 26 of 38
(1,684 Views)
Hi ekarl,
how do you read the jpg file? Which function do you use?
Use the read file function and connect the data output to the send vi.

Mike
0 Kudos
Message 27 of 38
(1,680 Views)
Here, you can look at my VI's. Smiley Happy

Download All
0 Kudos
Message 28 of 38
(1,677 Views)
the recieve_pic one is actually the active one, and the passive one is the send_pic.
0 Kudos
Message 29 of 38
(1,677 Views)
Hi ekarl,
i can´t open your vi´s at the moment, but i think you have now all information you need. Smiley Happy Use the read from file vi and connect it with the same wire yhere my constant is, delete the constant and you can send the file.

Hope it helps.
Mike
0 Kudos
Message 30 of 38
(1,672 Views)