To connect to the server, you can use the Volley and the OKHTTP library. To make simple requests you can see in the post HERE
In the case of Whatsapp you said, you would risk saying on their server that they have an implementation of Google Cloud Messaging (GCM). The GCM works so that whenever the user installs and runs the application for the first time, it registers to the google server and the server returns a key that will identify the application on that device, then the app sends that key to the server (in this case whatsapp) and saves it to the bank associated with the logged in user. Whenever another user decides to send a message to this user, it goes to the table that has the key record associated with the user and this same server sends a message to the GCM with the key and the message and google delivers the information as well that the user or app is available.
More on the subject see the link HERE