Represents socket-related errors in the jsocketpp library.
SocketException is the standard exception type thrown by the jsocketpp socket library whenever a socket-related operation fails (such as connect, bind, send, or receive). It stores both an error code and a human-readable message describing the error.
The exception can be caught using a standard C++ try-catch block, making error handling robust and portable.
This exception inherits from std::runtime_error for compatibility with standard exception handling patterns and tools, and also from std::nested_exception to allow users to use std::throw_with_nested() for advanced error chaining.
Example: Catching and Handling Socket Exceptions
try {
Socket sock(
"example.com", 80);
sock.connect();
std::cerr << "Socket error (" << ex.code() << "): " << ex.what() << std::endl;
}
Exception class for socket-related errors in jsocketpp.
TCP client socket abstraction for jsocketpp.
Represents socket-related errors in the jsocketpp library.
Definition SocketException.hpp:58
TCP client connection abstraction (Java-like interface).
Definition Socket.hpp:91
A C++ socket library providing Java-style networking interfaces.
Definition BufferView.hpp:13
- Note
- This exception stores a copy of the error message and error code. It is not tied to any particular platform error format—use the code/message for display or logging.
-
jsocketpp itself does not throw nested exceptions, but this class enables developers using the library to opt into exception chaining if desired. This class is safe to use without exception chaining. If you don't need nested exceptions, simply construct and throw it normally.
- Author
- MangaD
- Date
- 2025
- Version
- 1.0