 #include <sys/time.h>
 
 int gettimeofday(struct timeval* tp, void* tzp) 
 {
     DWORD t = timeGetTime();
     tp->tv_sec = t / 1000;
     tp->tv_usec = t % 1000;
     return 0;
 }
 
You need to link with either -lws2_32 (Winsock 2) or -lwsock32 (Winsock 1).

Looks like you need to call WSAStartup (),


memset(hostname, 0, 256);


^^^^^^^^^^^^^^^^

BOOL QueryPerformanceFrequency(
	LARGE_INTEGER *lpFrequency // address of current frequency
);

BOOL QueryPerformanceCounter( 
	LARGE_INTEGER *lpPerformanceCount // pointer to counter value 
);

typedef union _LARGE_INTEGER { 
struct {
	DWORD LowPart;
	LONG HighPart;
	};
	LONGLONG QuadPart;
} LARGE_INTEGER;


