Skip to content
Snippets Groups Projects
Commit e7e63434 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Merge branch 'ack' into develop

parents 334b290d f22af430
No related branches found
No related tags found
1 merge request!1Lento
......@@ -189,7 +189,7 @@ int Protocol::receive(int sockt, int type, int window, bool dataEndable){
if(status == NOISE){
continue;
} else if(status == type) {
if(messages.back().sequence.to_ulong() != nextSequence){
if(!messages.empty() && (messages.back().sequence.to_ulong() != nextSequence)){
response.reset();
vector<BYTE> val(1,(BYTE)nextSequence);
response.setData(val, NACK);
......@@ -199,6 +199,7 @@ int Protocol::receive(int sockt, int type, int window, bool dataEndable){
vector<BYTE> val(1,(BYTE)messages.back().sequence.to_ulong());
response.setData(val, ACK);
nextSequence = (messages.back().sequence.to_ulong()+1)%(MAXSIZE+1);
shouldSend = true;
} else {
//TODO: treat something?
}
......
......@@ -17,6 +17,7 @@ int main(){
}
if(status == CD){
cout << "Recebeu CD\n";
cout << "CD: " << receiveProtocol.getDataAsString() << endl;
cd(receiveProtocol.getDataAsString());
vector<BYTE> val(1,(BYTE)0);
sendProtocol.setData(val, OK);
......@@ -28,6 +29,7 @@ int main(){
cout << "LS: " << output << endl;
sendProtocol.setData(vector<BYTE>(output.begin(), output.end()), OUTPUT);
sendProtocol.transmit(sockt, WAIT_STOP);
cout << "finished transmit" << endl;
}else if(status == PUT){
//TODO
}else if(status == GET){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment