• Post Reply Bookmark Topic Watch Topic
  • New Topic

client-server protocol with odd error  RSS feed

John Kilbourne
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a program with selected code posted. Every second time through the client-server send-receive cycle, the client does not receive what the server sends.
In brief, client calls sendShowAll(), sending an int to the server which the server receives ok. The client also calls handleServerMessages, to listen for the server's reply.
The server, in a forever loop, receives the SHOWALL int and calls the single method sendShowAll(), followed by flush().
sendShowAll collects records using a JDBC Connection and assembles them into an array list. So far, all is well, the server verifies that it has done all these things. Since the array list is small, the server will send one partial packet. This is determined in sendShowAll, which then calls sendPartialPacket.
The server gets to here every time also, but something happens now that doesn't make sense. The server calls writeInt(PARTIALPACKET), and the client doesn't see it. This would tell the client to receive the partial packet and alter the data model for the table. The client only sees this message every second time this entire process iterates. Instead, the client sees BYE, a writeInt() call signaling that there is nothing more to send now, and the clilent needn't block on i/o.
I am baffled; please help if you can.
The client calls these two methods to update a table:
The server does this:{code]
while (true)
int command = in.readInt();
System.out.println("in main,command received: " +command);
System.out.println("in AddressServer; showall sent");
} break;
case DELETE:
int recNum = in.readInt();
System.out.println("deleted rec " + recNum);
} break;
case UPDATE:
ServerRecord sR = new ServerRecord();
System.out.println("Updated "+ sR);
case NEW:
ServerRecord sR = new ServerRecord();
} break;
}//end switch
System.out.println("bye code sent");
Then does this:
and this:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!