Fixed TCP Receive function

- Format checking for length prefix
Close Socket