The client needs to call recv in a loop cause the TCP subsystem is not able to serve such a huge buffer with one call. You will get the number of bytes read with each call and have to add the number of already received bytes to the buffer address passed with recv. Unfortunately, there is no safe way to find out when the read is complete beside the server has put the total size of bytes to send at the begin of the buffer where you can read it with the first call to recv.

The crashing probably is because the buffer provided by the client is too small.