File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
source/Octopus.TestPortForwarder Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public PortForwarder(Uri originServer,
4949 this . numberOfBytesToDelaySending = numberOfBytesToDelaySending ;
5050 var scheme = originServer . Scheme ;
5151
52- Start ( ) ;
52+ Start ( listeningPort ?? 0 ) ; // 0 means find a free port
5353 var ipEndPoint = listeningSocket . LocalEndPoint as IPEndPoint ?? throw new InvalidOperationException ( "listeningSocket.LocalEndPoint was not an IPEndPoint" ) ;
5454
5555 ListeningPort = ipEndPoint . Port ;
@@ -59,7 +59,7 @@ public PortForwarder(Uri originServer,
5959 }
6060
6161 [ MemberNotNull ( nameof ( listeningSocket ) ) ]
62- private void Start ( )
62+ private void Start ( int listeningPort )
6363 {
6464 if ( active )
6565 {
@@ -69,7 +69,7 @@ private void Start()
6969 listeningSocket ??= new Socket ( AddressFamily . InterNetwork , SocketType . Stream , ProtocolType . Tcp ) ;
7070 listeningSocket . NoDelay = true ;
7171
72- listeningSocket ! . Bind ( new IPEndPoint ( IPAddress . Loopback , ListeningPort ) ) ;
72+ listeningSocket ! . Bind ( new IPEndPoint ( IPAddress . Loopback , listeningPort ) ) ;
7373
7474 try
7575 {
You can’t perform that action at this time.
0 commit comments