You need to know how sockets and networking works.
Then you need to figure out how the game communicates (TCP, UDP, port(s)) with its servers, after that you need to figure out the protocols (known as the message structures).
After you have got that you simulate the network output like the original servers do.
A tip for new people, try to hard code the packet responses so you get into the game. Once you get into the game then stop the current project and start again from scratch and keep the first project as a reference. This time you start replacing the hard code structures with your emulated ones.
Good luck
@Taiga
Thank you for posting that. I was getting on to ask how to tell the difference between request packets from the client. I'm currently trying to build a server for SUN.