CreateSocket() fails on android

Socket creation fails on Android.

m_pSocket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("TEST"), false);

Engine\Source\Runtime\Sockets\Private\BSDSockets\SocketSubsystemBSD.cpp

FSocket* FSocketSubsystemBSD::CreateSocket(const FName& SocketType, const FString& SocketDescription, const FName& ProtocolType)
{

......

**#if PLATFORM_ANDROID
	// To avoid out of range in FD_SET
	if (Socket != INVALID_SOCKET && Socket >= 1024)
	{
		closesocket(Socket);
	}**
	else
#endif

......
}

It will fail even if you keep trying for few second.
It doesn’t happen on iOS.
Is there any way to avoid this?

1 Like