public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Jack Adrian Zappa <adrianh.bsc@gmail.com>
To: cygwin@cygwin.com
Subject: Re: nc fails to connect the first time and then succeeds
Date: Tue, 21 Apr 2020 11:14:10 -0400	[thread overview]
Message-ID: <CAKepmajsRwzkmqzjJsZqkk_eJSkSarTiJ8QGuxFzDAeWNG+3bw@mail.gmail.com> (raw)
In-Reply-To: <CAKepmaicf+zJDzgdTBQCHbjNqGXbm2yLWkrsxe6XYTucBk3FPg@mail.gmail.com>

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.

Thanks,

A

On Tue, Apr 21, 2020 at 3:48 AM Jack Adrian Zappa <adrianh.bsc@gmail.com> 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

  reply	other threads:[~2020-04-21 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21  7:48 Jack Adrian Zappa
2020-04-21 15:14 ` Jack Adrian Zappa [this message]
2020-04-21 16:30   ` Thomas Wolff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKepmajsRwzkmqzjJsZqkk_eJSkSarTiJ8QGuxFzDAeWNG+3bw@mail.gmail.com \
    --to=adrianh.bsc@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).