jsocketpp 1.0
A cross-platform C++20 socket library.
Loading...
Searching...
No Matches
jsocketpp::SocketTimeoutException Class Referencefinal

Exception class for socket operations that time out. More...

#include <SocketTimeoutException.hpp>

Inheritance diagram for jsocketpp::SocketTimeoutException:
Collaboration diagram for jsocketpp::SocketTimeoutException:

Public Member Functions

 SocketTimeoutException (const int errorCode=JSOCKETPP_TIMEOUT_CODE, std::string message="")
 Construct a new SocketTimeoutException with the specified or default timeout code and message.
Public Member Functions inherited from jsocketpp::SocketException
 SocketException (const std::string &message="SocketException")
 Constructs a SocketException with a custom error message and no associated error code.
 SocketException (const int code, const std::string &message="SocketException")
 Constructs a SocketException with a platform-specific error code and custom message.
 SocketException (const std::string &message, std::exception_ptr nested)
 Constructs a SocketException with a message and a nested exception.
int getErrorCode () const noexcept
 Retrieves the platform-specific error code associated with this exception.
std::exception_ptr getNestedException () const noexcept
 Retrieves the nested exception captured at construction time, if any.
 ~SocketException () override=default
 Destroys the SocketException.

Detailed Description

Exception class for socket operations that time out.

This exception is thrown when a socket operation (such as accept(), read(), or connect()) exceeds its allotted timeout period without completing. It provides a platform-appropriate error code and a human-readable message.

Inherits from SocketException and uses a default platform-specific error code:

  • Windows: WSAETIMEDOUT
  • POSIX: ETIMEDOUT

The default message is generated using SocketErrorMessage for the given timeout error code.

Example

try {
Socket client = server.accept(5000); // Wait up to 5 seconds
} catch (const SocketTimeoutException& e) {
std::cerr << "Timeout: " << e.what() << std::endl;
}
Exception class for socket operations that time out.
Definition SocketTimeoutException.hpp:39
TCP client connection abstraction (Java-like interface).
Definition Socket.hpp:93

Constructor & Destructor Documentation

◆ SocketTimeoutException()

jsocketpp::SocketTimeoutException::SocketTimeoutException ( const int errorCode = JSOCKETPP_TIMEOUT_CODE,
std::string message = "" )
inlineexplicit

Construct a new SocketTimeoutException with the specified or default timeout code and message.

Parameters
errorCodeThe platform-specific timeout code (default: JSOCKETPP_TIMEOUT_CODE).
messageOptional error message. If omitted, it will be generated from the error code.

The documentation for this class was generated from the following file: