Made a loop to recieve data from the socket and copy it to the dynamic
array.