C# Network programming
TCP sockets are, as a general rule, closed after every request. That's wrong. They will generally be closed when no subsequent data is required for some length of time. You don't want to make a new connection for every image on a webpage for instance. Your best bet to check what clients are connected would probably be a unique identifier sent in regular pings from the client, with a timeout so that if a client disconnects unexpectedly the server doesn't still think they are connected. This also allows for the client to change IP addresses without disconnecting, say they switch Wifi networks or use a mobile data connection.
Microsoft's help pages are actually very good with regards to network programming using .NET.
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now