Index: server/player.cpp
===================================================================
--- server/player.cpp	(revision 4da5aa37025782ca5ff28bdd917e8c134b884523)
+++ server/player.cpp	(revision 73f75c1b07aaa222ffc540cc36b7498a0bb8d6fc)
@@ -18,4 +18,5 @@
 }
 
+// was meant for the find find function. Currently unused
 bool player::operator == (const player &p)
 {
Index: server/player.h
===================================================================
--- server/player.h	(revision 4da5aa37025782ca5ff28bdd917e8c134b884523)
+++ server/player.h	(revision 73f75c1b07aaa222ffc540cc36b7498a0bb8d6fc)
@@ -8,9 +8,7 @@
 
 class player {
-private:
-   sockaddr_in addr;
-
 public:
    string name;
+   sockaddr_in addr;
 
    player(string name, sockaddr_in addr);
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 4da5aa37025782ca5ff28bdd917e8c134b884523)
+++ server/server.cpp	(revision 73f75c1b07aaa222ffc540cc36b7498a0bb8d6fc)
@@ -1,9 +1,6 @@
 #include "../common/compiler.h"
 
-#include <sys/types.h>
 #include <cstdlib>
 #include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
 #include <string>
 #include <netdb.h>
@@ -12,4 +9,8 @@
 #include <vector>
 #include <algorithm>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 #include <mysql/mysql.h>
@@ -41,4 +42,5 @@
 using namespace std;
 
+// this should probably go somewhere in the common folder
 void error(const char *msg)
 {
@@ -60,10 +62,25 @@
 }
 
+// not sure if we actually need this function
+// when I made it, I thought we did
+player *findPlayerByAddr(vector<player> &vec, sockaddr_in &addr)
+{
+   vector<player>::iterator it;
+
+   for (it = vec.begin(); it != vec.end(); it++)
+   {
+      if ( it->addr.sin_addr.s_addr == addr.sin_addr.s_addr &&
+           it->addr.sin_port == addr.sin_port )
+         return &(*it);
+   }
+
+   return NULL;
+}
+
 int main(int argc, char *argv[])
 {
    int sock, length, n;
-   socklen_t fromlen;
    struct sockaddr_in server;
-   struct sockaddr_in from;
+   struct sockaddr_in from; // holds the info on the connected client
    NETWORK_MSG clientMsg, serverMsg;
    vector<player> vctPlayers;
@@ -79,6 +96,6 @@
 
    if (argc < 2) {
-      fprintf(stderr, "ERROR, no port provided\n");
-      exit(0);
+      cerr << "ERROR, no port provided" << endl;
+      exit(1);
    }
    
@@ -92,5 +109,5 @@
    if ( bind(sock, (struct sockaddr *)&server, length) < 0 ) 
       error("binding");
-   fromlen = sizeof(struct sockaddr_in);
+
    while (true) {
       // if n == 0, means the client disconnected. may want to check this
@@ -98,6 +115,11 @@
       if (n < 0)
          error("recieveMessage");
-      cout << "MSG: type: " << clientMsg.type << " contents: " << clientMsg.buffer << endl;
-
+      cout << "ip address: " << inet_ntoa(from.sin_addr) << endl;
+      cout << "port: " << from.sin_port << endl;
+      cout << "MSG: type: " << clientMsg.type << endl;
+      cout << "MSG contents: " << clientMsg.buffer << endl;
+
+      // Check that if an invalid message is sent, the client will corectly
+      // receive and display the response. Maybe make a special error msg type
       switch(clientMsg.type)
       {
@@ -134,4 +156,9 @@
                strcpy(serverMsg.buffer, "That player is not logged in. This is either a bug, or you're trying to hack the server.");
             }
+            else if( p->addr.sin_addr.s_addr != from.sin_addr.s_addr ||
+                     p->addr.sin_port != from.sin_port )
+            {
+               strcpy(serverMsg.buffer, "That player is logged in using a differemt connection. This is either a bug, or you're trying to hack the server.");
+            }
             else
             {
@@ -144,17 +171,26 @@
          case MSG_TYPE_CHAT:
          {
-            int guess = atoi(clientMsg.buffer);
-
-            cout << "guess: " << guess << endl;
-
-            if (guess < 1 || guess > 1000) {
-               strcpy(serverMsg.buffer, "You must guess a number between 1 and 1000");
-            }else if(guess > num)
-               strcpy(serverMsg.buffer, "The number I'm thinking of is less than that.");
-            else if(guess < num)
-               strcpy(serverMsg.buffer, "The number I'm thinking of is greater than that.");
-            else if(guess == num) {
-               strcpy(serverMsg.buffer, "Congratulations! I will now think of a new number.");
-               num = (rand() % 1000) + 1;
+            player *p = findPlayerByAddr(vctPlayers, from);
+
+            if (p == NULL)
+            {
+               strcpy(serverMsg.buffer, "No player is logged in using this connection. This is either a bug, or you're trying to hack the server.");
+            }
+            else
+            {
+               int guess = atoi(clientMsg.buffer);
+
+               cout << "guess: " << guess << endl;
+
+               if (guess < 1 || guess > 1000) {
+                  strcpy(serverMsg.buffer, "You must guess a number between 1 and 1000");
+               }else if(guess > num)
+                  strcpy(serverMsg.buffer, "The number I'm thinking of is less than that.");
+               else if(guess < num)
+                  strcpy(serverMsg.buffer, "The number I'm thinking of is greater than that.");
+               else if(guess == num) {
+                  strcpy(serverMsg.buffer, "Congratulations! I will now think of a new number.");
+                  num = (rand() % 1000) + 1;
+               }
             }	
 
