Index: client/.gitignore
===================================================================
--- client/.gitignore	(revision e08572c6901857447bf2fa1df8b4e4fc85af10c4)
+++ client/.gitignore	(revision 0dde5da3a3881d418f8b65d612bd28cc4fcb5d0d)
@@ -4,2 +4,3 @@
 Client.sdf
 Client.opensdf
+client
Index: client/Client/main.cpp
===================================================================
--- client/Client/main.cpp	(revision e08572c6901857447bf2fa1df8b4e4fc85af10c4)
+++ client/Client/main.cpp	(revision 0dde5da3a3881d418f8b65d612bd28cc4fcb5d0d)
@@ -4,12 +4,13 @@
 
 #if defined WINDOWS
-	#include <winsock2.h>
-	#include <WS2tcpip.h>
+   #include <winsock2.h>
+   #include <WS2tcpip.h>
 #elif defined LINUX
-	#include <sys/types.h>
-	#include <unistd.h>
-	#include <sys/socket.h>
-	#include <netinet/in.h>
-	#include <netdb.h>
+   #include <sys/types.h>
+   #include <unistd.h>
+   #include <sys/socket.h>
+   #include <netinet/in.h>
+   #include <netdb.h>
+   #include <cstring>
 #endif
 
@@ -30,82 +31,102 @@
 using namespace std;
 
+void initWinSock();
+void shutdownWinSock();
 void error(const char *);
 
 int main(int argc, char *argv[])
 {
-	int sock, n;
-	struct sockaddr_in server, from;
-	struct hostent *hp;
-	char buffer[256];
-	NETWORK_MSG msgTo, msgFrom;
+   int sock, n;
+   struct sockaddr_in server, from;
+   struct hostent *hp;
+   char buffer[256];
+   NETWORK_MSG msgTo, msgFrom;
 
-	if (argc != 3) {
-		cout << "Usage: server port" << endl;
-		exit(1);
-	}
+   if (argc != 3) {
+      cout << "Usage: server port" << endl;
+      exit(1);
+   }
 
-	WORD wVersionRequested;
-	WSADATA wsaData;
-	int wsaerr;
+   initWinSock();
+	
+   sock = socket(AF_INET, SOCK_DGRAM, 0);
+   if (sock < 0)
+      error("socket");
 
-	wVersionRequested = MAKEWORD(2, 2);
-	wsaerr = WSAStartup(wVersionRequested, &wsaData);
+   server.sin_family = AF_INET;
+   hp = gethostbyname(argv[1]);
+   if (hp==0)
+      error("Unknown host");
+
+   memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
+   server.sin_port = htons(atoi(argv[2]));
+
+   strcpy(msgTo.buffer, "Hello");
+   n=sendMessage(&msgTo, sock, &server);
+   if (n < 0)
+      error("sendMessage");
+
+   n = receiveMessage(&msgFrom, sock, &from);
+   if (n < 0)
+      error("receiveMessage");
 	
-	if (wsaerr != 0) {
-		cout << "The Winsock dll not found." << endl;
-		exit(1);
-	}else
-		cout << "The Winsock dll was found." << endl;
+   cout << msgFrom.buffer << endl;
+
+   while(true) {
+      cout << "Please enter a message (or q to quit): ";
+      cin.getline(msgTo.buffer, 256);
+		
+      if (strcmp(msgTo.buffer, "q") == 0) {
+         break;
+      }
+
+      n=sendMessage(&msgTo, sock, &server);
+      if (n < 0)
+         error("sendMessage");
+
+      n = receiveMessage(&msgFrom, sock, &from);
+      if (n < 0)
+         error("receiveMessage");
+
+      cout << msgFrom.buffer << endl;
+   }
+
+#if defined WINDOWS
+   closesocket(sock);
+#elif defined LINUX
+   close(sock);
+#endif
+
+   shutdownWinSock();
+
+   cout << "Thank you for playing!" << endl;
+   getchar();
+
+   return 0;
+}
+
+void initWinSock()
+{
+#if defined WINDOWS
+   WORD wVersionRequested;
+   WSADATA wsaData;
+   int wsaerr;
+
+   wVersionRequested = MAKEWORD(2, 2);
+   wsaerr = WSAStartup(wVersionRequested, &wsaData);
 	
-	sock= socket(AF_INET, SOCK_DGRAM, 0);
-	if (sock < 0)
-		error("socket");
+   if (wsaerr != 0) {
+      cout << "The Winsock dll not found." << endl;
+      exit(1);
+   }else
+      cout << "The Winsock dll was found." << endl;
+#endif
+}
 
-	server.sin_family = AF_INET;
-	hp = gethostbyname(argv[1]);
-	if (hp==0)
-		error("Unknown host");
-
-	memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-	server.sin_port = htons(atoi(argv[2]));
-
-	strcpy(msgTo.buffer, "Hello");
-	n=sendMessage(&msgTo, sock, &server);
-	if (n < 0)
-		error("sendMessage");
-
-	n = receiveMessage(&msgFrom, sock, &from);
-	if (n < 0)
-		error("receiveMessage");
-	
-	cout << msgFrom.buffer << endl;
-
-	while(true) {
-		cout << "Please enter a message (or q to quit): ";
-		cin.getline(msgTo.buffer, 256);
-		
-		if (strcmp(msgTo.buffer, "q") == 0) {
-			break;
-		}
-
-		n=sendMessage(&msgTo, sock, &server);
-		if (n < 0)
-			error("sendMessage");
-
-		n = receiveMessage(&msgFrom, sock, &from);
-		if (n < 0)
-			error("receiveMessage");
-	
-		cout << msgFrom.buffer << endl;
-	}
-
-	closesocket(sock);
-
-	WSACleanup();
-
-	cout << "Thank you for playing!" << endl;
-	getchar();
-
-	return 0;
+void shutdownWinSock()
+{
+#if defined WINDOWS
+   WSACleanup();
+#endif
 }
 
@@ -113,6 +134,6 @@
 void error(const char *msg)
 {
-    perror(msg);
-	WSACleanup();
-    exit(1);
+   perror(msg);
+   shutdownWinSock();
+   exit(1);
 }
Index: common/compiler.h
===================================================================
--- common/compiler.h	(revision e08572c6901857447bf2fa1df8b4e4fc85af10c4)
+++ common/compiler.h	(revision 0dde5da3a3881d418f8b65d612bd28cc4fcb5d0d)
@@ -1,11 +1,11 @@
 #if defined _WIN64
-	#define WINDOWS
+   #define WINDOWS
 #elif defined _WIN32
-	#define WINDOWS
+   #define WINDOWS
 #elif defined __linux
-	#define LINUX
+   #define LINUX
 #elif defined __unix
-	#define LINUX
+   #define LINUX
 #elif defined __posix
-	#define LINUX
+   #define LINUX
 #endif
Index: common/message.cpp
===================================================================
--- common/message.cpp	(revision e08572c6901857447bf2fa1df8b4e4fc85af10c4)
+++ common/message.cpp	(revision 0dde5da3a3881d418f8b65d612bd28cc4fcb5d0d)
@@ -4,21 +4,21 @@
 
 #if defined WINDOWS
-	#include <winsock2.h>
-	#include <WS2tcpip.h>
+   #include <winsock2.h>
+   #include <WS2tcpip.h>
 #elif defined LINUX
-	#include <sys/socket.h>
-	#include <netinet/in.h>
+   #include <sys/socket.h>
+   #include <netinet/in.h>
 #endif
 
 int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
 {
-	return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
+   return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
 }
 
 int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
 {
-	socklen_t socklen = sizeof(struct sockaddr_in);
+   socklen_t socklen = sizeof(struct sockaddr_in);
 
-	// assume we don't care about the value of socklen
-	return recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, &socklen);
+   // assume we don't care about the value of socklen
+   return recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, &socklen);
 }
Index: common/message.h
===================================================================
--- common/message.h	(revision e08572c6901857447bf2fa1df8b4e4fc85af10c4)
+++ common/message.h	(revision 0dde5da3a3881d418f8b65d612bd28cc4fcb5d0d)
@@ -6,6 +6,6 @@
 typedef struct
 {
-	short type;
-	char buffer[256];
+   short type;
+   char buffer[256];
 } NETWORK_MSG;
 
