HttpServerLite icon indicating copy to clipboard operation
HttpServerLite copied to clipboard

System.Net.Sockets.SocketException

Open CatgirlLunya opened this issue 4 years ago • 10 comments

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); }

CatgirlLunya avatar Dec 23 '21 19:12 CatgirlLunya

That means you have something else listening on that TCP port.

jchristn avatar Dec 23 '21 19:12 jchristn

It happens to every port I choose

CatgirlLunya avatar Dec 23 '21 19:12 CatgirlLunya

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?

jchristn avatar Dec 23 '21 19:12 jchristn

Windows 10 19043 .NET 4.x in unity 2020.3.25f1

CatgirlLunya avatar Dec 23 '21 19:12 CatgirlLunya

Does the Test project work?

jchristn avatar Dec 23 '21 20:12 jchristn

No, I can't compile it due to a missing reference.

CatgirlLunya avatar Dec 23 '21 20:12 CatgirlLunya

Attempting to install the Library in the test project throws 42 errors, they're all about the missing stuff in the code

CatgirlLunya avatar Dec 23 '21 20:12 CatgirlLunya

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?

jchristn avatar Dec 23 '21 20:12 jchristn

Even running as admin doesn't work

CatgirlLunya avatar Dec 23 '21 20:12 CatgirlLunya

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.

jchristn avatar Dec 23 '21 21:12 jchristn