System.Net.Sockets.SocketException
SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
Code:
Variable private Webserver _webserver;
Constructor:
_webserver = new Webserver("localhost", 8000, IndexHtml); _webserver.Start();
My IndexHtml method:
private async Task IndexHtml(HttpContext ctx) { string data = Resources.Load<TextAsset>("OptionsWeb/index.html").text; ctx.Response.ContentLength = data.Length; ctx.Response.ContentType = "text/html"; ctx.Response.StatusCode = 200; await ctx.Response.SendAsync(data); }
That means you have something else listening on that TCP port.
It happens to every port I choose
Do you experience this with the Test project as well? https://github.com/jchristn/HttpServerLite/tree/master/Test
Which operating system are you using, which version, and which runtime and version are you using?
Windows 10 19043 .NET 4.x in unity 2020.3.25f1
Does the Test project work?
No, I can't compile it due to a missing reference.
Attempting to install the Library in the test project throws 42 errors, they're all about the missing stuff in the code
Got it. It might have something to do with Unity then. Running in .NET 4.6x works fine here; can you try running as admin?
Even running as admin doesn't work
Got it. Not sure, I don't have the Unity environment set up. I will do my best to test this when I can. Sorry for the issue and for the delay.