blob: 267e8dae80079a48934567a252b57d6d8c5aa354 [file] [log] [blame]
Brian Silvermanf7bd1c22015-12-24 16:07:11 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2015. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#ifndef TCPSOCKETS_SOCKETERROR_H_
9#define TCPSOCKETS_SOCKETERROR_H_
10
11#include <string>
12
13#ifdef _WIN32
14#include <WinSock2.h>
15#else
16#include <errno.h>
17#endif
18
19namespace tcpsockets {
20
21static inline int SocketErrno() {
22#ifdef _WIN32
23 return WSAGetLastError();
24#else
25 return errno;
26#endif
27}
28
29std::string SocketStrerror(int code);
30
31static inline std::string SocketStrerror() {
32 return SocketStrerror(SocketErrno());
33}
34
35} // namespace tcpsockets
36
37#endif // TCPSOCKETS_SOCKETERROR_H_