And in the server code I check if the same player attack twice.
Here is the dilemma. User 1 click on the board to attack and immediately read back the result from his attack. Idle responsible for send the result back. But if user 1 try to attack twice then, strange thing start to happen. After the first attack, right now it should sit the myIdle() trying to read in something (where the stars is). If user 1 try to attack twice or three time.., seems like the program queue up his attack, and when user 2 click on the board. All the attack from user1 click got draw. So instead of sending the attack to the server, which then detect as an attack from the same client, Now it is a valid attack, because it queue up the attack and wait for the user 2 to attack. How can I fix this problem? Thank you

I can't understand exactly what your problem, it seems like you should have some stages like Playing, Waiting for counter attack etc, in which the networking is dealt with different. You could try to read and understand this in case it helps http://fax.twilightcoders.net/BATOL%20SHIPZ/ .

Sounds like you need a bit of logic to prevent the client from queuing multiple attack messages. Presumably, this would be done by preventing additional attacks until the remote server sends the client an acknowledgment that the attack message has been processed, and that it's the client's turn to attack again. Having the server verify that it's receiving sane data from the client (a single well-formed attack message) would also be highly advisable.

Maybe put an id on your messages. This way you could send as many of the same message as you need and the server will only process the first one it receives and ignores the rest. This id will change for each unique message you send to the server. I'm guessing UDP is being used.