|
|
|
|
|
by pkolaczk
1830 days ago
|
|
The playground link confirms the socket is closed after dropping networkComponent. Last two lines of the output: Dropping NetworkComponent
Dropping NetworkSocket
Btw: you probably fooled yourself by accidentally creating 2 sockets, and indeed the first one gets dropped immediately when you lose (overwrite) the reference to it. Use Option to avoid that. |
|
By replacing the socket now the port number is another one, and all processes that had open connections to that port will now crash, or have messages dropped without getting why.
I can also fabricate plenty of error situations with Rust if you feel so inclined.
And if you were actually serious, you would be aware that there are Roslyn analysers that validate IDispose follows proper RAII patterns, like https://github.com/DotNetAnalyzers/IDisposableAnalyzers
Remember, Rust isn't perfect, and only fixes 70% of existing error patterns, I can have plenty of inspiration with the remaining 30%.