I'm using a MacBook Air M2 with the latest macOS 26.4.
SSH.net in version 2025.1.0 (tested also the latest develop branch), .NET in version 10.
ssh executable works fine.
I'm trying to forward a local port to my server.
|
_listener = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true }; |
|
_listener.Bind(ep); |
|
_listener.Listen(5); |
|
if (!_listener.AcceptAsync(e)) |
Every port I try, $${\color{purple}Bind}$$ throws System.Net.Sockets.SocketException (48): Address already in use.
Even though $${\color{purple}Listen}$$ in the next line is never called nor $${\color{purple}AcceptAsync}$$, the tunnel works.
Even after the application is closed.
The left side is my MacBook, the right side the server.

My test code:
using var sshClient = new SshClient("server", 22, "oliver", "password");
sshClient.Connect();
var local = new ForwardedPortLocal(12345, "127.0.0.1", 5000);
sshClient.AddForwardedPort(local);
try {
local.Start();
} catch (Exception ex) {
Console.WriteLine(ex);
}
Console.Write("Press ENTER to exit");
Console.ReadLine();
Does anyone have an explanation for this?
I'm using a MacBook Air M2 with the latest macOS 26.4.
SSH.net in version 2025.1.0 (tested also the latest develop branch), .NET in version 10.
ssh executable works fine.
I'm trying to forward a local port to my server.
SSH.NET/src/Renci.SshNet/ForwardedPortLocal.cs
Lines 193 to 195 in 25a931c
SSH.NET/src/Renci.SshNet/ForwardedPortLocal.cs
Line 229 in 25a931c
Every port I try,$${\color{purple}Bind}$$ throws $${\color{purple}Listen}$$ in the next line is never called nor $${\color{purple}AcceptAsync}$$ , the tunnel works.
System.Net.Sockets.SocketException (48): Address already in use.Even though
Even after the application is closed.
The left side is my MacBook, the right side the server.

My test code:
Does anyone have an explanation for this?