X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0062F384B0C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=towo.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=towo AT towo DOT net Subject: Re: nc fails to connect the first time and then succeeds To: cygwin AT cygwin DOT com References: From: Thomas Wolff X-Tagtoolbar-Keys: D20200421183018709 Message-ID: <502440b5-0c10-ab66-930b-dbb2304d9550@towo.net> Date: Tue, 21 Apr 2020 18:30:18 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K1:zxP73fJp2wDzkbt0/ZY9J/OKSP3mWZxyY8U/q2oSkiaJzO0ZqeP WeuhJ448RoJ0KMt99ItWfpvdPc/HyajASHT6A/EDsImMnxgzDmkfEorKTrhrmTW7wYO3kwo vLGpIZRAG8fSbwhJBx/u0/1BtKJjR4/E1kRPiYuXMoU5iQTOsIpvqU3NdMbobWoe7OAf6h4 2uEE9rVxm8d//GXuP5tqw== X-UI-Out-Filterresults: notjunk:1;V03:K0:CZ0SX61GL4Q=:n6ANYU1YuOMnYQ5LSdOXdH zgiesub+c8ONN+15IDeD9d8lTGPLg6z43rZYDZEsY5shvHiSsB2u04z8UAHS+nINLwYNxnaHx vQIp3gMZ9QaumF2cf/+ZvCn6Fmwsa3ExVGvT1CrMWuQ2qiNsDmUWvGF3mh4gj/SZKjFsBX0C8 Amcwi7lVLoBj1lv2ELAAF+y8zMw6DoILFh2dK9cr8SqXR7Rgd4F8A0+4ZvCj9X9TIaKBsKy6T tY7JRbfTSIv8RnJeQg38HxOwibWVFUZ8OZRu5L3/RvsXmHsa66StlD6XSi+tGVmQebvau6QNM iaTs95djWp0HIa4AwPBq/7KUAO38rBp/mAVgd+KwGw+5hkwnmBpGcv3WiPhPIliC6YZ+cTJ1Z 9zSwq6XZL0l85OvSuqwvOdibAmrJwnBlh0oFZthQk5pZwsJmZaY8IkXl+I0mihJzAL/uH72mE murZ8hD0DNMnwYBdkE512do9pmPEQtJcuEMiG7Lljv6YBiLSLbvfiiQkhYFtdDmZMTYQhb+QQ vcSXh8C3Ggo3sYZOczrnJqR9zu/W7bIZ2tiqbnOV2Rkw73dbk1m+V7OhhWcsojoa8+FVIJwXh axL8goNVtiH/mpwGG9Hg1ELC23OyUs91ilaIaEIQJxQMVsuyXZRugZq6vqSr3wu3q5Jc6rPRs 2P5L9F+0B3FGLAFFTko9H4dcGvXDObDSvviO2nmR/fc4DUkQHaFyA+KF2q2borrUf1K57bbex I8iy0n33XyhWy2zaklPjn7mNoFT8VBGOrkx95G8sE3TeuRoOijV/Xv8RdrsDDDbghBAUVhdmh tzjhT2ZWpF+WWshWF8ttEZUDnOsOxVA9xvEB5OAdPW+06RIUa4= X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" Please don't "top-post". Am 21.04.2020 um 17:14 schrieb Jack Adrian Zappa via Cygwin: > Nm. I figured it out. Seems if you don't specify what type of > listener, it'll default to IP4. When you create a sender, it'll try > first using IP6 and then fall back to IP4. It's that first connection > that is causing the failure. If you specify the listener to use IP6, > then it works fine. OK, but what's the solution? How do you specify that in your scenario? > > Thanks, > > A > > On Tue, Apr 21, 2020 at 3:48 AM Jack Adrian Zappa wrote: >> I was trying to do some testing of a ssh port forwarding issue I was >> having, by trying to reduce the problem into something simpler. So I >> reached for netcat (nc). Turns out that when trying to connect a >> listener to a sender directly, it will fail first and then succeed. >> >> Example: >> In terminal 1 we do: >> >> $ nc -l 1234 >> >> nc waits. In terminal 2 we do: >> >> $ nc -v localhost 1234 >> nc: connect to localhost port 1234 (tcp) failed: Connection refused >> Connection to localhost 1234 port [tcp/*] succeeded! >> >> The initial failure is fine when connecting directly, but this failure >> is disastrous when connecting through an ssh connection. This is >> because when the sshd connects to the nc listener, it will first fail >> and then succeed. However, that first failure makes the sshd think >> that there is no connection to be had and just closes the tunnel, >> making the nc sender just terminate. >> >> Is this a coding error or somehow by design? If by design, then why? >> If by error, then when can we expect this to be fixed? >> >> Thanks, >> >> >> Adrian > -- > Problem reports: https://cygwin.com/problems.html > FAQ: https://cygwin.com/faq/ > Documentation: https://cygwin.com/docs.html > Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple