Setting NetworkServer.dontListen to true after starting server doesn't close socket properly
Describe the bug
So this was an issue I was dealing with for a long time. I eventually figured out that the socket wasn't being closed because the NetworkServer skips closing the socket if NetworkServer.dontListen is true. What makes this more frustrating is that Telepathy doesn't have this issue. KCP does and I believe that this was the reason why I was getting issues with Ignorance, mentioned here: https://github.com/SoftwareGuy/Ignorance/issues/60#issuecomment-654042619
Repro project https://drive.google.com/file/d/1b9EdHud78aeqbol2mucnleX9ndbOoF9V/view?usp=sharing
To Reproduce Steps to reproduce the behavior:
- Open the attached project
- Open the sample scene
- Select the NetworkManager
- Hit the Bugged Start Host button on the BugReproduction component
- Hit the Stop Host button
- Hit the Bugged Start Host button again and error
Expected behavior
At the very least if you set NetworkServer.dontListen to true when you've started a server already you should get an error.
Desktop (please complete the following information):
- OS: Windows 10
- Build target: Windows
- Unity version: 2019..4.16f1
- Mirror branch: Asset store latest as of 1/8/2021 (30.2.1)
The don't listen logic might actually be jank. I'll see if I can trace the feature and see if there's room for improvement.
dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense
dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense
Perhaps dontListen should have a setter that shuts down the listening.
dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense
Perhaps dontListen should have a setter that shuts down the listening.
Ideally, I think it'd be best to somehow make it so that variables that should not be modified at runtime should not be able to be accessed during runtime. Say instead you pass an argument when starting a client/server/host. Though I'd imagine this'd be more effort than it's worth to make happen.
Not fixed