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 int code, const std::string &message="SocketException")
int getErrorCode () const noexcept
 ~SocketException () override=default

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 SocketErrorMessageWrap 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:91

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: