public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* nc fails to connect the first time and then succeeds
@ 2020-04-21  7:48 Jack Adrian Zappa
  2020-04-21 15:14 ` Jack Adrian Zappa
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Adrian Zappa @ 2020-04-21  7:48 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-21 16:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21  7:48 nc fails to connect the first time and then succeeds Jack Adrian Zappa
2020-04-21 15:14 ` Jack Adrian Zappa
2020-04-21 16:30   ` Thomas Wolff

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).