From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 21 03:05:52 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id ECFD01CC for ; Sun, 21 Jul 2013 03:05:52 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from outgoing.tristatelogic.com (segfault.tristatelogic.com [69.62.255.118]) by mx1.freebsd.org (Postfix) with ESMTP id CAC37ED2 for ; Sun, 21 Jul 2013 03:05:52 +0000 (UTC) Received: from segfault-nmh-helo.tristatelogic.com (localhost [127.0.0.1]) by segfault.tristatelogic.com (Postfix) with ESMTP id C1EF23AD8F; Sat, 20 Jul 2013 20:05:46 -0700 (PDT) From: "Ronald F. Guilmette" To: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= Subject: Re: bin/176713: [patch] nc(1) closes network socket too soon In-Reply-To: Date: Sat, 20 Jul 2013 20:05:46 -0700 Message-ID: <24574.1374375946@server1.tristatelogic.com> Cc: FreeBSD Hackers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 03:05:53 -0000 In message =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= wrote: >It seems to work for me: Good. Just to make sure that we are clear, you are simply confirming what my bug report (bin/176713) said, i.e. that _without_ my fix, nc can prematurely truncate the output from some servers, whereas _with_ my fix this bad behaviour on the part of nc is cured... Is that correct? If so, thank you for confirming that my proposed fix produces the desired result. I feel compelled to say again that in actual point of fact, the way that I personally would prefer to see this problem resolved would *not* be to add a new option for the nc program. Rather, I think that it would actually be best simply to delete from the nc source code the one single line that is causing nc to stop its operation as soon as it receives an EOF from its stdin channel. If that line is simply deleted, then nc will instead wait until it receives an EOF from the remote server that it is talking to, and quite obviously, this change causes nc to produce output which is arguably more correct and which is certainly more useful that the prematurely truncated results that nc sometimes produces at present. >> P.P.S. I have just realized that yet one more critical enhancement for >> nc is called for, and I will be filing a separate and additional PR for >> that soon. I hope that someone will be able to take a look at that as >> soon as it is filed. > >Just out of curiosity. What is it about? Well, as it turns out, the additional "fix" that I had believed that I was going to propose for nc was not that critical after all... at least not for my current and immediate application(s). However it might still have some value in some cases anyway, so I will describe what I had in mind. Quite simply, I believe that it would be Good if the nc program had a new and additional option which, when used, would cause nc to refrain from sending any data _to_ the remote server until such time as it had received one entire line _from_ the remote server. Such an option could be useful when using nc to communicate with remote servers running certain protocols. For example, the rules of the SMTP protocol... just to name one... require that a client wait until the server has sent out an initial greeting banner before the client sends anything to the server. Some SMTP servers are lenient about enforcing this protocol rule, so in practice it may often not be necessary to wait for the greeting banner before sending SMTP commands from the client to the server. However there may perhaps be other instances where waiting actually is required, and thus I believe that an option to produce that kind of behavior might be a useful addition to the nc command. Regards, rfg