#pragma once

#if (defined WIN32 || defined __CYGWIN__)

	#ifndef WIN32_LEAN_AND_MEAN
	#define WIN32_LEAN_AND_MEAN
	#endif

	#if _WIN32_WINNT < 0x0500
	#define _WIN32_WINNT 0x0500
	#endif

	#pragma warning(disable : 4786)

	//#ifdef __cplusplus
	//	#include <atlbase.h>
	//#endif

	#include <windows.h>
	#include <MMSystem.h>
	#include <malloc.h>

	#include <fcntl.h>
	#include <WinSock2.h>
	#include <ws2tcpip.h>
	#include <process.h>
	#include <io.h>
	#include <time.h>
	#include <new>
	#include <stdarg.h>
#if (_MSC_VER >= 1400)
	#include <emmintrin.h>
#endif

	#ifndef SIO_UDP_CONNRESET
	#define SIO_UDP_CONNRESET           _WSAIOW(IOC_VENDOR,12)
	#endif


	#pragma comment(lib,"ws2_32.lib")
	#pragma comment(lib,"winmm.lib")

	typedef int		socklen_t;
#if !defined(__MINGW32__)
typedef HANDLE pthread_t;
typedef HANDLE pthread_mutex_t;
typedef HANDLE pthread_cond_t;
typedef DWORD pthread_key_t;
#endif
	typedef __int64      int64;
	typedef unsigned __int64 QWORD;
#else

	#include <string.h>
	#include <stdlib.h>
	#include <stdio.h>
	#include <errno.h>
	#include <dirent.h>
	#include <stdarg.h>
	#include <ctype.h>
	#include <sys/stat.h>
	#include <sys/types.h>


	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <pthread.h>
	#include <fcntl.h>


	#ifdef __LITEOS__
		#include <lwip/netdb.h>

		#ifndef SIOCGIFCONF
		#define SIOCGIFCONF	0x8912		/* get iface list		*/
		#endif

		#ifndef AI_PASSIVE
		#define AI_PASSIVE     0x1  /* Socket address will be used in bind() call */
		#endif

	#else
		#include<netinet/ip.h>
		#include <arpa/inet.h> 
		#include <netdb.h>
	#endif


	#include <sys/time.h>
	#include <unistd.h>
	#include <sys/ioctl.h> 
	//	#include <net/if.h> 

	#ifndef PHOSTENT
	typedef struct hostent *PHOSTENT;
	#endif

	#ifndef SOCKADDR_IN
	typedef struct sockaddr_in SOCKADDR_IN;
	#endif


	#define INFINITE            0xFFFFFFFF  //  无限等待(无超时)
	typedef unsigned long			PointerSizedInt;
	typedef unsigned char   		UInt8;
	typedef char					Int8;
	typedef unsigned short  		UInt16;
	typedef short					Int16;
	typedef unsigned int			UInt32;
	typedef int						Int32;
	typedef long long				Int64;
	typedef unsigned long long  	UInt64;
	typedef float               	Float32;
	typedef double              	Float64;

	typedef unsigned long			ulong;
	typedef unsigned long 			DWORD;
#if defined(__x86_64__) || defined(__aarch64__) || defined(__LP64__)
	typedef unsigned long 			UINT_PTR;
#else
	typedef unsigned int 			UINT_PTR;
#endif
	typedef UInt8					BYTE;
	typedef long					LONG;
	typedef Int64					INT64;
	typedef Int32					INT32;
	typedef unsigned int			UINT32;
	typedef UInt16					WORD;
	typedef unsigned long long		UINT64;
	typedef unsigned int			UINT;
	typedef UInt8					*PBYTE;
	typedef int						SOCKET;

	typedef unsigned long long uint64;
#ifndef ARM_FUHAN_RTOS
	typedef signed int   int32_t;
#endif
	typedef unsigned char uint8_t;
	typedef unsigned short uint16_t;

	typedef unsigned char byte;
	typedef unsigned char uint8;
	typedef unsigned short uint16;
	typedef unsigned int   uint32;
	typedef short   int16;
	typedef int      int32;
	typedef char *LPSTR;

	#if !defined( __LITEOS__)
		#ifndef BOOL

		#ifdef __APPLE__
			typedef signed char	BOOL;
		#else
			typedef void*					Handle;
			typedef long	BOOL;
		#endif

		#endif

		#ifndef TRUE
		#define TRUE			1
		#define FALSE			0
		#endif
	#endif

	#define MAX_TIMEOUT		0xFFFFFFFF
	#define INVALID_SOCKET	-1
	#define SOCKET_ERROR	-1

	#ifndef CALLBACK
	#define CALLBACK
	#endif

	#ifndef FAR
	#define FAR
	#endif


	#ifndef CALLBACK
	#define CALLBACK
	#endif
	#ifndef WINAPI
	#define WINAPI
	#endif



	#ifndef SOCKADDR
		typedef struct sockaddr SOCKADDR;
	#endif

	#define MAX_PATH          260

	#define __max(a,b)	(((a) > (b)) ? (a) : (b))
	#define __min(a,b)	(((a) < (b)) ? (a) : (b))



#endif

#ifdef __cplusplus
	#include <math.h>
	#include <fstream>
	#include <map>
	#include <string>
	#include <list>
	#include <vector>
	using namespace std;
#else
	#define bool int;
	#define true	1
	#define false	0
#endif


typedef int UDX_INT32 ;
typedef unsigned int UDX_UINT32 ;

typedef unsigned int UDP_LONG ;
typedef unsigned short UDP_SHORT ;
typedef BYTE UDP_BYTE ; 
typedef long UDX_LONG;
typedef unsigned long UUDX_LONG;

