Bug 185353

Summary: nc(1) does not exit after transfer (should be documented)
Product: Documentation Reporter: Robert <rol>
Component: Books & ArticlesAssignee: Allan Jude <allanjude>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Robert 2013-12-30 22:50:01 UTC
nc is supposed to close connection after file transfer as described in man page.

machineA or TerminalB $ nc -l 12345 > foo.txt
machineC or TerminalD $ nc machineA 12345 < bar.txt

The connection in the example above hangs until nc is interrupted on one side.
Adding -d (don't read from stdin) on the listening side is ignored.
Redirecting input from /dev/null (nc -l 12345 > foo.txt < /dev/null) on the listening side aborts before the whole file (200k in my case) was transfered.
This happens also from 10.0-RC3 -> 9.1-R, but not the other way round.

How-To-Repeat: see description
Comment 1 peter 2013-12-31 00:40:42 UTC
     -N      shutdown(2) the network socket after EOF on the input.  Some
             servers require this to finish their work.

Try:  "nc -N machineA 12345 < bar.txt" from your example

-- 
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV
Yes, I know, gmail sucks now. If you see this then I forgot. Habits
are hard to break.
Comment 2 Robert 2014-01-01 15:10:24 UTC
On Mon, 30 Dec 2013 16:40:42 -0800, Peter Wemm wrote
> -N      shutdown(2) the network socket after EOF on the input.  
> Some             servers require this to finish their work.
> 
> Try:  "nc -N machineA 12345 < bar.txt" from your example

Hi,

you're right. It works.
Then it should be documented in the example in the man page as nc 
now belongs to "some servers" that require this to finish their work.

Regards,
Robert

> -- 
> Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; 
> KI6FJV Yes, I know, gmail sucks now. If you see this then I forgot. Habits
> are hard to break.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2014-01-06 00:07:44 UTC
Responsible Changed
From-To: freebsd-amd64->freebsd-docs

reclassify.
Comment 4 Allan Jude 2014-02-10 16:28:30 UTC
This is a multi-part message in MIME format.
Comment 5 Allan Jude 2014-02-10 20:04:09 UTC
The fix has been committed to OpenBSD.

http://marc.info/?l=openbsd-cvs&m=139206012706972&w=2

There have been a few other updates to netcat in the mean time, although
they are to do with FD passing, which I suspect is an OpenBSD only feature.

Hopefully Xin Li or someone else can MFV and pull in the fix for the man
page.

-- 
Allan Jude
Comment 6 Allan Jude freebsd_committer freebsd_triage 2014-05-20 07:30:28 UTC
State Changed
From-To: open->closed

Updated man page (by Allan Jude) merged from vendor (OpenBSD 5.5) to  
head in r264361 by Xin Li 


Comment 7 Allan Jude freebsd_committer freebsd_triage 2014-05-20 07:30:28 UTC
Responsible Changed
From-To: freebsd-docs->allanjude

Updated man page (by Allan Jude) merged from vendor (OpenBSD 5.5) to 
head in r264361 by Xin Li
Comment 8 Allan Jude freebsd_committer freebsd_triage 2014-11-14 22:38:57 UTC
Note: this fix was released as part of FreeBSD 10.1