简体   繁体   中英

What's the recommended way of handling Winsock errors in C++?

What's the recommended way of handling Winsock errors in C++?

Checking the return code of every Winsock function you call in your application?

Or

Handling errors through exception handling (something like SocketException : public std::exception)?

Or

Both?

Since Winsock itself doesn't throw exceptions, the only way to handle errors is to check the return code of functions you call.

If you write your own layer on top of Winsock that throws your own exceptions, then your application code could respond to exceptions. But that's up to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM