I was using ForwardedPortRemote to connect to a VNC server behind a NAT, and connecting via
var port1 = new ForwardedPortRemote(remotePort, "127.0.0.1", localPort);
connected to the IPv6 address rather than 127.0.0.1. I changed OpenSocket in ChannelForwardedTcpip.NET40.cs to:
partialvoid OpenSocket(string connectedHost, uint connectedPort) { IPEndPoint ep;string sPattern = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";if (System.Text.RegularExpressions.Regex.IsMatch(connectedHost, sPattern)) { ep = new IPEndPoint(IPAddress.Parse(connectedHost), (int)connectedPort); } else { ep = new IPEndPoint(Dns.GetHostEntry(connectedHost).AddressList[0], (int)connectedPort); }this._socket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);this._socket.Connect(ep);this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1); }
and got it to work. Could this be changed in the source, or is there a better way to do this?