when i use multicast data with udp ,i can send data but can not receive ! Please tell me what’s wrong?
void AUdpActor::StartUdp()
{
//send socket
FIPv4Endpoint EndPoint1(FIPv4Address(231, 255, 255, 255), port);
RemoteAddr = EndPoint1.ToInternetAddr();
UdpSenderSocket = FUdpSocketBuilder(TEXT("UpdSendSocket"))
.AsReusable()
.WithBroadcast()
.WithSendBufferSize(2 * 1024 * 1024)
.WithReceiveBufferSize(2 * 1024 * 1024);
if (UdpSenderSocket)
{
isStartUdpSucessful = true;
GLog->Logf(TEXT("Send socket create succesful"));
}
//receiver socket
FIPv4Endpoint EndPoint2(FIPv4Address::Any, port);
UdpReceiverSocket = FUdpSocketBuilder(TEXT("UpdReceiverSocket"))
.AsNonBlocking()
.AsReusable()
.BoundToEndpoint(EndPoint2)
.WithMulticastLoopback()
.WithReceiveBufferSize(2 * 1024 * 1024);
if (UdpReceiverSocket)
{
GLog->Logf(TEXT("Receiver socket create succesful"));
FTimespan ThreadWaitTime = FTimespan::FromMilliseconds(100);
UdpReceiver = new FUdpSocketReceiver(UdpReceiverSocket, ThreadWaitTime, TEXT("Udp Receiver"));
UdpReceiver->OnDataReceived().BindUObject(this, &AUdpActor::RecvData);
UdpReceiver->Start();
}
}