diff --git a/Protocol.cpp b/Protocol.cpp
index bc6593ad29d8b04dea1d99a520aa07e84c48026f..1758dba87f1a3329c2231f8ec75cff6732d296b5 100644
--- a/Protocol.cpp
+++ b/Protocol.cpp
@@ -10,28 +10,40 @@ void Protocol::setMessage(Message message){
     this->message = message;
 }
 
+vector<BYTE> Protocol::getData(){
+    return data;
+}
+
+string Protocol::getDataAsString(){
+    string str(data.begin(), data.end());
+    return str;
+}
+
+void Protocol::setData(vector<BYTE> data){
+    this->data = data;
+}
+
 int Protocol::readMessage(int sockt){
-    unsigned char dataRec[MAXSIZE+4];
-    int ret = recv(sockt, dataRec, MAXSIZE, 0);
+    BYTE dataRec[MAXSIZE+4];
+    recv(sockt, dataRec, MAXSIZE, 0);
     Message msg;
     msg.c_ctrl.begin = dataRec[0];
     if(msg.i_ctrl.begin != BEGIN){
-        return 0;
+        return -1;
     }
     msg.c_ctrl.size = dataRec[1];
     msg.c_ctrl.seqType = dataRec[2];
     msg.c_ctrl.parity = dataRec[3+msg.i_ctrl.size];
     // TODO: Check parity
-    if(msg.i_ctrl.type == FIM){
-        this->message = msg;
-        return 1;
+    if(msg.i_ctrl.type == ENDTX){
+        return ENDTX;
     }
 
-    unsigned char msgData[msg.i_ctrl.size];
+    BYTE msgData[msg.i_ctrl.size];
     memcpy(msgData,dataRec+3,msg.i_ctrl.size);
     this->data.insert(this->data.end(), msgData, msgData+msg.i_ctrl.size);
     this->message = msg;
-    return -1;
+    return msg.i_ctrl.type;
 }
 
 Protocol::Protocol(){
diff --git a/Protocol.h b/Protocol.h
index ea1d57dc351d55c4a51ec252a89a173a493bd092..4794e522b08ed08811dc52e288f515dfc6197fcf 100644
--- a/Protocol.h
+++ b/Protocol.h
@@ -6,13 +6,16 @@ class Protocol{
 
 private:
     Message message;
-    vector<unsigned char> data;
+    vector<BYTE> data;
     int timeout;
 public:
 
     Message getMessage();
     void setMessage(Message message);
-    int readMessage(int socket);
+    vector<BYTE> getData();
+    void setData(vector<BYTE> data);
+    string getDataAsString();
+    int readMessage(int sockt);
 
     Protocol();
 };
diff --git a/definitions.h b/definitions.h
index 02c948f4662fd8f4c302a03c3e820d7bfd20091c..747b71cb4e3a777ade7be522dddf1b62a7ef95c0 100644
--- a/definitions.h
+++ b/definitions.h
@@ -7,10 +7,10 @@
 
 using namespace std;
 
-#define MAXSIZE 64
-#define MINSIZE 60
+#define MAXSIZE 64 //number maximum of bytes in data field
+#define MINSIZE 60 //number minimum of bytes in data field
 
-#define BEGIN 0x7E
+#define BEGIN 0x7E //begin delimiter value
 
 #define DEVICE "lo"
 #define NACK 0
@@ -20,10 +20,13 @@ using namespace std;
 #define PUT 5
 #define GET 6
 #define OK 8
-#define TAM 9
-#define TELA 10
-#define ERRO 14
-#define FIM 15
+#define SIZE 9
+#define OUTPUT 10
+#define DATA 13
+#define ERROR 14
+#define ENDTX 15
+
+#define BYTE unsigned char
 
 typedef struct{
 	int begin   : 8,
diff --git a/dirFunctions.cpp b/dirFunctions.cpp
index 527175cb079ae822ee40beccefbfeea5360b2472..bb8964a28e48d098d6051a59ce72882a376d9752 100644
--- a/dirFunctions.cpp
+++ b/dirFunctions.cpp
@@ -3,9 +3,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <vector>
-#include <numeric> //accumulate
 #include <stdio.h> //popen
-#include <iterator>
 
 using namespace std;
 
@@ -28,15 +26,4 @@ string ls(string args){
     }
     pclose(lsOut);
     return output;
-    //TODO: #1
-    // struct dirent *entry;
-    // DIR *dir = opendir(path.c_str());
-    // if(dir != NULL){
-    //     while((entry=readdir(dir)) != NULL){
-    //        cout << entry->d_name << endl;
-    //     }
-    //     closedir(dir);
-    // }else{
-    //     cout<<"Error: could not open directory."<<endl;
-    // }
 }
\ No newline at end of file
diff --git a/server.cpp b/server.cpp
index 9f1688c79611b655bdab4da2f9d406ce7864cb6d..a877aeadceccef2f324d9dfb03676897f7ca4a64 100644
--- a/server.cpp
+++ b/server.cpp
@@ -1,17 +1,31 @@
 #include "definitions.h"
+#include "dirFunctions.h"
 #include "ConexaoRawSocket.c"
 
 int main(){
-	int sockt = ConexaoRawSocket(DEVICE);
-	Protocol protocol;
-	while(true){
-		int ret = protocol.readMessage(sockt);
-		if(ret){
-			if(ret == 1){
-				//End of transmission
-			}
-			//TODO: Check window sequence and blablabla
-		}
-	}
-	return 0;
+    int sockt = ConexaoRawSocket(DEVICE);
+    Protocol protocol;
+    while(true){
+        int status = protocol.readMessage(sockt);
+        if(status > 0){
+            if(status == ENDTX){
+                protocol = Protocol();
+                if(protocol.getMessage().i_ctrl.type == DATA){
+                    //TODO: send ACK
+                }
+            }else if(status == CD){
+                cd(protocol.getDataAsString());
+            }else if(status == LS){
+                string output = ls(protocol.getDataAsString());
+                //TODO: send output back
+            }else if(status == PUT){
+                //TODO
+            }else if(status == GET){
+                //TODO
+                //intesristing link: http://stackoverflow.com/questions/15138353/reading-the-binary-file-into-the-vector-of-unsigned-chars
+            }
+            //TODO: Check window sequence and blablabla
+        }
+    }
+    return 0;
 }
\ No newline at end of file