How can I receive data from another application using socket?

Hello, I’m trying to get the data from another application using socket. So, I’ve made the socket server in Unreal Engine and trying to receive the data. But, It made the unreal engine freezed and killed. I think it is pending in the HasPendingData function. How can i solve this problem? I

TArray ReceivedData;

uint32 Size;

while (**ConnectionSocket->HasPendingData(Size)**)
{

	ReceivedData.Init(FMath::Min(Size, 65507u), 0);
		
	int32 Read = 0;
	bool bGetReceived = ConnectionSocket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
}