WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SocketError.h
1 /*----------------------------------------------------------------------------*/
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 
19 namespace tcpsockets {
20 
21 static inline int SocketErrno() {
22 #ifdef _WIN32
23  return WSAGetLastError();
24 #else
25  return errno;
26 #endif
27 }
28 
29 std::string SocketStrerror(int code);
30 
31 static inline std::string SocketStrerror() {
32  return SocketStrerror(SocketErrno());
33 }
34 
35 } // namespace tcpsockets
36 
37 #endif // TCPSOCKETS_SOCKETERROR_H_