Skip to content

Commit 14a8e0b

Browse files
committed
Fix port use
1 parent f058c2f commit 14a8e0b

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

ServeMeLib/ServeMe.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ internal string CanOpenDefaultBrowserOnStart(string root)
394394
}
395395

396396
//https://stackoverflow.com/questions/570098/in-c-how-to-check-if-a-tcp-port-is-available
397-
internal bool PortInUse(int port)
397+
internal bool PortNotInUse(int port)
398398
{
399399
bool isAvailable = true;
400400
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
@@ -433,7 +433,7 @@ internal List<List<string>> GetVariablesFromSettings()
433433
if (this.ExtractFromSettings("app sslport", out data) == 2)
434434
{
435435
int port = int.Parse(data[1]);
436-
if (this.PortInUse(port))
436+
if (!this.PortNotInUse(port))
437437
throw new Exception($"Ssl Port {port} in setting is in use");
438438
return port;
439439
}
@@ -446,7 +446,7 @@ internal List<List<string>> GetVariablesFromSettings()
446446
if (this.ExtractFromSettings("app port", out data) == 2)
447447
{
448448
int port = int.Parse(data[1]);
449-
if (this.PortInUse(port))
449+
if (!this.PortNotInUse(port))
450450
throw new Exception($"Port {port} in setting is in use");
451451
return port;
452452
}

ServeMeLib/SimpleHttpServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public SimpleHttpServer(ServeMe serveMe, int? port = null, int? portHttps = null
145145
}
146146
if (portHttps == null)
147147
{
148-
var allowableHttpsPortsByVisualStudio = Enumerable.Range(44300, 33399).ToList();
148+
var allowableHttpsPortsByVisualStudio = Enumerable.Range(44300, 44399).ToList();
149149

150150
for (int i = 0; i < allowableHttpsPortsByVisualStudio.Count; i++)
151151
{
152-
if (!serveMe.PortInUse(allowableHttpsPortsByVisualStudio[i]))
152+
if (serveMe.PortNotInUse(allowableHttpsPortsByVisualStudio[i]))
153153
{
154154
portHttps = allowableHttpsPortsByVisualStudio[i];
155155
serveMe.Log($"Yay! Found https port {portHttps} to use ....");

0 commit comments

Comments
 (0)