sdlNetUdpSetPacketLoss function

void sdlNetUdpSetPacketLoss(
  1. Pointer<UDPsocket> sock,
  2. int percent
)

Set the percentage of simulated packet loss for packets sent on the socket.

SDL_net can optionally, at random, drop packets that are being sent and received, to simulate bad networking conditions. As these sort of conditions can happen in the real world but likely won't between machines on the same LAN, you can use this function in testing to make sure your app is robust against network problems even on a fast, reliable network.

You probably don't want to use this function outside of local testing.

\param sock the socket to simulate packet loss on. \param percent a value from 0 to 100 of likelihood to drop a packet (higher the number means more likelihood of dropping.

\since This function is available since SDL_net 2.0.0.

extern DECLSPEC void SDLCALL SDLNet_UDP_SetPacketLoss(UDPsocket sock, int percent)

Implementation

void sdlNetUdpSetPacketLoss(Pointer<UDPsocket> sock, int percent) {
  final sdlNetUdpSetPacketLossLookupFunction = libSdl2Net.lookupFunction<
      Void Function(Pointer<UDPsocket> sock, Int32 percent),
      void Function(
          Pointer<UDPsocket> sock, int percent)>('SDLNet_UDP_SetPacketLoss');
  return sdlNetUdpSetPacketLossLookupFunction(sock, percent);
}