added ping-pong networking example

Signed-off-by: Jak Barnes <contact@jakbarnes.co.uk>
This commit is contained in:
Jak Barnes 2019-02-16 00:44:30 +00:00
commit bb01a49398

View file

@ -45,36 +45,58 @@
#define MMNOSOUND
//----------------------------------------------------------------------------------
// Platform specific network includes
//----------------------------------------------------------------------------------
#define PLATFORM_WINDOWS 1
#define PLATFORM_MAC 2
#define PLATFORM_UNIX 3
#if defined(_WIN32)
#define PLATFORM PLATFORM_WINDOWS
#elif defined(__APPLE__)
#define PLATFORM PLATFORM_MAC
//----------------------------------------------------------------------------------
// Platform defines
//----------------------------------------------------------------------------------
#define PLATFORM_WINDOWS 1
#define PLATFORM_UNIX 2
#if defined(__WIN32__) || defined(WIN32)
#define PLATFORM PLATFORM_WINDOWS
#else
#define PLATFORM PLATFORM_UNIX
#endif
#if PLATFORM == PLATFORM_WINDOWS
// #define _INC_WINDOWS
// #define WIN32_LEAN_AND_MEAN
// #include <minwindef.h>
#endif
#if PLATFORM == PLATFORM_WINDOWS
#include <winsock2.h>
#elif PLATFORM == PLATFORM_MAC || PLATFORM == PLATFORM_UNIX
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#if PLATFORM == PLATFORM_WINDOWS
#pragma comment(lib, "wsock32.lib")
#endif
//----------------------------------------------------------------------------------
// Platform specific network includes
//----------------------------------------------------------------------------------
#if PLATFORM_WINDOWS
#define __USE_W32_SOCKETS
#pragma comment(lib, "ws2_32.lib")
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#else /* UNIX */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netdb.h>
#endif /* WIN32 */
/* System-dependent definitions */
#ifndef __USE_W32_SOCKETS
#define closesocket close
#define SOCKET int
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#endif /* __USE_W32_SOCKETS */
#ifdef __USE_W32_SOCKETS
#define RNet_GetLastError WSAGetLastError
#define RNet_SetLastError WSASetLastError
#ifndef EINTR
#define EINTR WSAEINTR
#endif
#else
int RNet_GetLastError(void);
void RNet_SetLastError(int err);
#endif