if you're expecting one simple piece of code. then there's no way you'd be ready to make a game work well online.
it is incredable complicated (unless its as "simple" as the example AoDC mentioned, but i wouldnt call that a game
)
take a look at the example AoDC mentioned and if you dont seem to be able to understand parts of it, then you wont be ready to do something so complicated im afraid.
for example, it's taking me years to get very used to gamemaker (i did start programming with it though) and a couple more years from starting on experiementing on making games online (with about 3 or 4 attempts at games, which did get quite far in the stage of a *basic* engine) for me to be able to confidently work on the MORPG i'm working on now. which has taken months and months to get what may not seem too far, but boy, it's got one hell of a lot of code in it. (although i have made a few small games (not mmorpg style) with simple multiplayer, but that online code wasn't too good at all. it wouldn't really do for a game to be released, but it was ok just for a laugh with friends. but it was still just as difficult)
so it will take a lot of time and experiences to be able to prodcue a worthwhile online game.
dealing with lag, in an online game, is one of the hardest things to do.