报错:
LogSockets: Warning: Tried to bind address with protocol None to a socket with protocol IPv4
LogUDPCommand: Error: Failed to bind listen socket to addr () for Matchmaking UDP
代码:
// InitSocket()
//
// Task: Init everything
//
bool UMatchmakingUDPComponent::InitSocket(int32 port)
{
// Prepare Temp Variables
bool bSuccess = false;
ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
ListenAddr->SetPort(port);
// Create the needed Socket
ListenSocket = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("UDP Matchmaking"), true);
if (ListenSocket == NULL)
{
UE_LOG(LogUDPCommand, Error, TEXT("Failed to create listen socket for Matchmaking UDP"));
return false;
}
// Set config
ListenSocket->SetReuseAddr();
ListenSocket->SetNonBlocking();
ListenSocket->SetRecvErr();
// Try to bind
if (ListenSocket->Bind(*ListenAddr))
return true;
// Binding failed -> Log Error
else {
UE_LOG(LogUDPCommand, Error, TEXT("Failed to bind listen socket to addr (%s) for Matchmaking UDP"), *ListenAddr->ToString(true));
return false;
}
}
// InitSocket()