1 //====== Copyright Valve Corporation, All rights reserved. ====================
2 //
3 // Include the relevant platform-specific headers for socket-related stuff,
4 // and declare some functions make them look similar
5 //
6 
7 #ifndef STEAMNETWORKINGSOCKETS_PLATFORM_H
8 #define STEAMNETWORKINGSOCKETS_PLATFORM_H
9 #pragma once
10 
11 // Socket headers
12 #ifdef _WIN32
13 	//#include <windows.h>
14 	#include <winsock2.h>
15 	#include <ws2tcpip.h>
16 	#include <iphlpapi.h>
17 	#define MSG_NOSIGNAL 0
18 	#undef SetPort
19 #elif defined( NN_NINTENDO_SDK )
20 	// Sorry, but this code is covered under NDA with Nintendo, and
21 	// we don't have permission to distribute it.
22 #else
23 	#include <sys/types.h>
24 	#include <sys/socket.h>
25 	#include <netinet/in.h>
26 	#include <sys/ioctl.h>
27 	#include <unistd.h>
28 	#include <poll.h>
29 	#include <errno.h>
30 
31 	#include <sys/types.h>
32 	#ifndef ANDROID
33 		#include <ifaddrs.h>
34 	#endif
35 	#include <sys/ioctl.h>
36 	#include <net/if.h>
37 
38 	#ifndef closesocket
39 		#define closesocket close
40 	#endif
41 	#ifndef ioctlsocket
42 		#define ioctlsocket ioctl
43 	#endif
44 	#define WSAEWOULDBLOCK EWOULDBLOCK
45 #endif
46 
47 // Windows is the worst
48 #undef min
49 #undef max
50 
GetLastSocketError()51 inline int GetLastSocketError()
52 {
53 	#if defined( _WIN32 )
54 		return (int)WSAGetLastError();
55 	#elif defined( NN_NINTENDO_SDK )
56 		// Sorry, but this code is covered under NDA with Nintendo, and
57 		// we don't have permission to distribute it.
58 	#else
59 		return errno;
60 	#endif
61 }
62 
63 #endif // #ifndef STEAMNETWORKINGSOCKETS_PLATFORM_H
64