Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

System.Net.Sockets.SocketException #9

Open
mldchan opened this issue Dec 23, 2021 · 10 comments
Open

System.Net.Sockets.SocketException #9

mldchan opened this issue Dec 23, 2021 · 10 comments

Comments

@mldchan
Copy link

mldchan commented Dec 23, 2021

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

@jchristn
Copy link
Owner

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

@mldchan
Copy link
Author

mldchan commented Dec 23, 2021

It happens to every port I choose

@jchristn
Copy link
Owner

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?

@mldchan
Copy link
Author

mldchan commented Dec 23, 2021

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

@jchristn
Copy link
Owner

Does the Test project work?

@mldchan
Copy link
Author

mldchan commented Dec 23, 2021

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

@mldchan
Copy link
Author

mldchan commented Dec 23, 2021

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

@jchristn
Copy link
Owner

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?

@mldchan
Copy link
Author

mldchan commented Dec 23, 2021

Even running as admin doesn't work

@jchristn
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants