LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending ZIP files through TCP/IP

Solved!
Go to solution

Hi there!

 

I have compressed two hours sensor data (the data is stored in .csv file) into zip file. After reading several examples on TCP/IP connections, I know that I need to send the size first and followed by the file. The connection is established between the two PCs but the trouble is about sending the size of the zip file and the file itself.

I tried to send the size using the "Get File Size" function and type cast it into first tcp write function but it returns me error code 1 which I believe it is invalid parameter.

As for the file I used the strip path to obtain the zip file and type cast it into second tcp write function.

What is the input used for the size and file? 

0 Kudos
Message 1 of 9
(4,447 Views)

Attach your VI so we can see what you are doing!

 

I don't know why you would use Strip Path to send a file.

 

Sending a zip file through TCP/IP shouldn't be any different than sending any other file, or any other binary data.

 

 

0 Kudos
Message 2 of 9
(4,432 Views)

What is listening on the other end?

I assume that the receiver is also a LabVIEW program that you can modify. 

 

On the sender side

  • Read the file as simple string.
  • Get the resulting string length
  • Get the length of the file name
  • Send the name lenght and the file name
  • Send the data lenght and the data
  • Close the connection

 

On the receiving end:

  • Wait for a connection.
  • read the file name length
  • read the file name
  • read the data length
  • Read the data
  • Write the data to a local file using a local default folder and the received name. Resolve conflicts if the file already exists, etc.
  • Wait for the next connection.

 

Of course if the receiving end is a standard server (e.g. ftp), you could use datasocket functions instead.

0 Kudos
Message 3 of 9
(4,418 Views)

Hi there! Unable to reply asap as I was busy on other stuffs. Thanks for the reply.

By the way, I solved the error code 1 problem. It is because I wired the wrong id (listener id), I just change it to connection id and it worked. Now, I am having the problem of error 66, after sending the file size but cannot create the zip file.

 

Below attached image on how the zip file is sent and where the error 66 occurred.

 

Download All
0 Kudos
Message 4 of 9
(4,320 Views)

You never read or send the content of the file. read my instructions again.

 

(Please attach the actual VI, we cannot debug pictures and we cannot see what's in the subVI)

0 Kudos
Message 5 of 9
(4,306 Views)

Is snippet okay? I made some of modification of the code using read and write from binary file.

The zip file created but it is corrupted.

The content of abc.zip is just random .txt files as I can't really upload the real file (privacy problem).

Download All
0 Kudos
Message 6 of 9
(4,302 Views)

Below zip file contains both sender and receiver vis. They are the same as you see in those snippets.

0 Kudos
Message 7 of 9
(4,292 Views)

 

I don't understand the case where you create a zip file. That makes no sense. The zip file is created when you write the received binary string to file (with the existing zip extension)

 

(That's it for now. There are many other things that are quite confusing....)

0 Kudos
Message 8 of 9
(4,286 Views)
Solution
Accepted by topic author CharlesGoh

Hey guys, I have solved the problem. When I feed in the file size into "read from binary file" function, it worked like charm. Thanks everyone!

0 Kudos
Message 9 of 9
(4,264 Views)