هلا جميع ...
كيف ممكن انى اخلي الكلاينت يرسل ارقام ( انتجر فاليوا ) .. للسيرفر ... ويقوم السيرفر بجمع هذه الارقام .... ؟!
المكشله عندي فقط في عميله الجمع .... مب عارفه كيف اضبطها ..... بليز ممكن حد يشوفلي حل .... ؟!
هذا هوه جزء من الكود ياريت اذا ممكن اي شخص يقدر يعدل عليه ... ومشكورين ... :)
private void processConnection() throws IOException
{
int getNum, total=0;
// send connection successful message to client
String message = "SERVER>>> Connection successful";
output.writeObject( message );
output.flush();
// enable enterField so server user can send messages
enterField.setEnabled( true );
// process messages sent from client
do {
// read message and display it
try {
message = ( String ) input.readObject();
displayArea.append( "\n" + message );
getNum = Integer.parseInt( message);
total = total + getNum;
output.writeObject(Integer.toString(total));
output.flush();
displayArea.setCaretPosition(
displayArea.getText().length() );
}
// catch problems reading from client
catch ( ClassNotFoundException classNotFoundException ) {
displayArea.append( "\nUnknown object type received" );
}
catch (ArithmeticException wrongFormat) {
displayArea.append("\nwrong object format, not numbers! final total=" + total);
}
} while ( !message.equals( "CLIENT>>> TERMINATE" ) );
}