Multiplayer games - Where do I put the game logic?

I’m a rookie at game development, and I have a question about multiplayer games.

Let’s say I’m doing the classic “Pong-game”. The game is played over the internet from two different clients. Both clients have event-handlers that moves the players own paddle when he/she press the right buttons on the keyboard. The koordinates of the own paddle is sent to the opponent, and the opponents paddle-position is recieved. But what about the ball? The ball should bounce at walls and at the paddles, but where do I put the logic for that? In one of the clients or both?

In my first version of this game I put this logic in one of the clients. In this client the code checks to see if the ball should bounce. It also moves the ball. The ball coordinates is then sent to the other client.

Is this the wrong way to go? The reason I chose this way to go was that I was afraid that the ball might be on different positions in the clients. With my technique I always know that the ball is in the same position in both clients. But maybe that’s the case anyway?

My though was that because I use the UDP-protocol, packets might be lost during transfer. Let’s say client1 s paddle is moving up, but during the transfer of the new coordinates, some packets is lost. The paddle moves up and reflects the incoming ball on client1s screen, but in client2s screen the paddle don’t move up (because of the lost packets) and misses the ball. This will mean that the ball will be in different position on the two clients screens.

I feel I might be thinking in the wrong direction, but I just want to clear this thing out ones and for all.

I hope someone will take the time to answer my question because I believe it is important for me to know this so I’ll be able to make a little more advanced games in the future.

Thanks! //David