sending data to server and storing it into a buffer