I actually like Aron_dc's answer, but i thought I would add an answer to provide additional things to consider.
1) UDP vs TCP - You have to choose a particular protocol and understand the cost and benefits. Picking UDP is quicker, but you have to create your own control code on top of UDP, common problems with UDP : packet loss, firewalls, packets out of order and knowing when the client has disconnected (using timers and "are you alive" packets). With UDP you may have to think about storing packets, numbering them and resending them if they don't get acknowledge. It maybe a bit of a headache for the first time.
2) Multiplayer component design:
- State machine : how many states the client may have : connecting, playing, disconnecting, changing level?
- Components : What are you sending to the client and to the server? Login information, inventory, movement, chat.
- Acks/Nacks : If something happens in the game : like a player dies or wall get destroyed, does every client have to say "yeah i got that information", because if the don't the game state will desynchronize and everyone will be playing their version of the game. (PS: I played a game once with bad multiplayer code and it was kind of funny to know that while I was winning the game on my machine, it was not the case on the other player's machine.)
You need to have a good handle on understand serialization, as it will also help you write save/load game functionality as well. Essentially it is taking your objects and storing them in a different format. So for example you want to serialize movement message.
MovementMessage(int x, int y, int z);
byteBuffer.write(MOVEMENT_MESSAGE_TYPE); // a unique number that lets you know it is movement message
messageType = byteBuffer.readInt();
msg = new MovementMessage()
msg.x = byteBuffer.getInt();
msg.y = byteBuffer.getInt();
msg.z = byteBuffer.getInt();
If you want to send multiple messages in one packet you may add additional details to your protocol, for example
[how many messages] [first message] [second message]
02 01 1 2 3 01 2 3 4
two messages, first message is of type 01 with data 1,2,3 and second is also type 01 with data 1,2,3
There are two libraries that I am thinking of right off the bat : Google Proto Buffers and Java Netty. I have had a lot of experience with java netty and use it in my projects. It has example for clients and servers. There are probably more.
When I do multiplayer research, I usually try to find out how the other guys did it. I look up information on Quake, Unreal and other popular titles and read up how they designed their multiplayer component. Once you can understand the design the rest is just picking the right code to do it.