socket error handler
parent
822d926651
commit
2280046f14
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
|
|
||||||
set(BLT_VERSION 0.15.8)
|
set(BLT_VERSION 0.15.9)
|
||||||
set(BLT_TEST_VERSION 0.0.1)
|
set(BLT_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Brett Terpstra
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BLT_ERROR_H
|
||||||
|
#define BLT_ERROR_H
|
||||||
|
|
||||||
|
namespace blt::error
|
||||||
|
{
|
||||||
|
|
||||||
|
void print_socket_error();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //BLT_ERROR_H
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Brett Terpstra
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <blt/std/error.h>
|
||||||
|
#include <blt/std/logging.h>
|
||||||
|
|
||||||
|
namespace blt
|
||||||
|
{
|
||||||
|
void print_socket_error()
|
||||||
|
{
|
||||||
|
switch (errno)
|
||||||
|
{
|
||||||
|
case EINVAL:
|
||||||
|
BLT_WARN("Invalid argument");
|
||||||
|
break;
|
||||||
|
case EACCES:
|
||||||
|
BLT_WARN("Permission denied");
|
||||||
|
break;
|
||||||
|
case EPERM:
|
||||||
|
BLT_WARN("Operation not permitted");
|
||||||
|
break;
|
||||||
|
case EADDRINUSE:
|
||||||
|
BLT_WARN("Address already in use");
|
||||||
|
break;
|
||||||
|
case EADDRNOTAVAIL:
|
||||||
|
BLT_WARN("Cannot assign requested address");
|
||||||
|
break;
|
||||||
|
case EAFNOSUPPORT:
|
||||||
|
BLT_WARN("Address family not supported by protocol");
|
||||||
|
break;
|
||||||
|
case EAGAIN:
|
||||||
|
BLT_WARN("Try again");
|
||||||
|
break;
|
||||||
|
case EALREADY:
|
||||||
|
BLT_WARN("Operation already in progress");
|
||||||
|
break;
|
||||||
|
case EBADF:
|
||||||
|
BLT_WARN("Bad file number");
|
||||||
|
break;
|
||||||
|
case ECONNREFUSED:
|
||||||
|
BLT_WARN("Connection refused");
|
||||||
|
break;
|
||||||
|
case EFAULT:
|
||||||
|
BLT_WARN("Bad address");
|
||||||
|
break;
|
||||||
|
case EINPROGRESS:
|
||||||
|
BLT_WARN("Operation now in progress");
|
||||||
|
break;
|
||||||
|
case EINTR:
|
||||||
|
BLT_WARN("Interrupted system call");
|
||||||
|
break;
|
||||||
|
case EISCONN:
|
||||||
|
BLT_WARN("Transport endpoint is already connected");
|
||||||
|
break;
|
||||||
|
case ENETUNREACH:
|
||||||
|
BLT_WARN("Network is unreachable");
|
||||||
|
break;
|
||||||
|
case ENOTSOCK:
|
||||||
|
BLT_WARN("Socket operation on non-socket");
|
||||||
|
break;
|
||||||
|
case EPROTOTYPE:
|
||||||
|
BLT_WARN("Protocol wrong type for socket");
|
||||||
|
break;
|
||||||
|
case ETIMEDOUT:
|
||||||
|
BLT_WARN("Connection timed out");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue