You could look up the code for a simple chatroom, and make sure the network functionality is robust enough before integrating it into your game.
After all, network communication is no different from a simple chat, you just process the messages differently (not to mention you'll want to be able to send chat text too).
As for the mentioned LAN/WAN difference, if you have a TCP/IP capable client/server architecture, you have both options. The only relevant difference, as has been mentioned above, is scanning for servers, which on a LAN can be easily managed because you know the IP range of all devices on the same subnet.
For WAN (Internet) play, either players need to know their connection IP (your game could provide this information) and manually enter it to connect, or there needs to be a master server that players connect to in order to find open games (which could be set up easily on a website, but it might require upkeep).
Providing direct IP capabilities is important, as you might be on a LAN, but on different subnets, which could render your server search function useless.
If I may go on a tangent, this issue really irks me about gaming today. Despite what publishers claim, all games are perfectly LAN capable, as they have TCP/IP capabilities, yet in increasingly many cases they restrict this by forcing the user to rely on the online master server for matchmaking, which means that, once the owners inevitably turn the server off, the game's online mode becomes useless.
I find it sad that old games had more flexibility just by allowing users to manually type the server IP address than current games.