I send the file with cat file1 | nc ip-address port and receive it with nc -l port > file2 and get the file cut. The size of the received file is 28467200 bytes (approx. 28M) out of approx. 150M.

uname -a
Linux MyName 3.13.0-107-generic #154-Ubuntu SMP Tue Dec 20 09:57:27 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

On other linux I have (Loki in VirtualBox inside Windows7) this limitation is not available.

uname -a
Linux Loki-VirtualBox 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

I also used other software as a sending side with same result, therefore I blame the receiving part.

In Wireshark I see the (FIN, ACK) flag which makes the connection to close, but I cannot find any reason for it.

What could be a reason for such behavior?

EDIT: In case I use nc -l port > filename I receive 28M of data, but if I use nc -l port > filename < /dev/null, I receive 26K of data (took from this question: Sending file via netcat). Is this behavior somehow related?

  • How much is missing? From where - start, end, one or more random blocks? – AFH Mar 14 '17 at 11:32
  • I receive always about 28M. The sample files are much bigger, about 150M. I receive only the beginning of the file. – avp Mar 14 '17 at 12:38
  • It looks like a network problem: you should redirect stderr at each end, and see if there is anything in the error logs. Also, try the transfer with both sender and receiver on the local machine, using as the sender IP. By the way, never use cat file | program ... - always use the much more efficient program <file .... – AFH Mar 14 '17 at 13:18
  • Yes, I have already tested the localhost, it makes no difference. Only that PC, only that nc (or system, whatever) have this limitation. For the stderr I did not get the idea. I see nothing in terminal. IMHO the stderr output would appear there, wouldn't it? I mean, the pipe redirects only the stdout, the stderr would be visible. Am I wrong? – avp Mar 14 '17 at 14:56
  • I wasn't sure how you were accessing or monitoring the remote system, so I wasn't sure if you'd see stderr messages. When you say that using localhost makes no difference, do you mean that the same error occurs? On both systems? Have you tried sending a similarly-sized file the other way? – AFH Mar 14 '17 at 16:12

You're receiving the file incorrectly.

You should listen for it with

nc -l -p port > file2

And send it with

cat file1 | nc ip port
|improve this answer|||||
  • Ah, crap, it's a typo here. I received as you have written. I fix the question not to mislead others though. Thank you anyway. – avp Mar 14 '17 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.