Implementing functions. Connecting and receiving from the server