🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

how disconnected ?

Started by
0 comments, last by Menelvagor 23 years, 10 months ago
How can I understand my connection gets disconnected using Win32 API ? Thanks.
Advertisement
For TCP if the other side did a graceful shutdown recv will return 0. Otherwise, just be sure to check for errors whenever you do anything. ECONNRESET is a typical error you get back when the other side just dies for no reason, but you could get others.

For UDP you don''t have a real connection and thus you can''t tell when the other side goes away. Your best bet is to just have a timeout in your app. If you don''t hear anything after a certain amount of time assume the other guy died.

-Mike

This topic is closed to new replies.

Advertisement