new socket issue

Mark Geib <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
In order to join a source-specific multicast group I am trying the new socket module. I am able to join the multicast and start receiving datagrams by spawning the function below. The gen_udp module does not support joining a source-specific multicast currently.

active_socket(Socket, Parent, Timeout) ->
  case socket:recvfrom(Socket, 0, [], Timeout) of
    {ok, {#{port := Port, addr := Addr}, Data}} ->
      Parent ! {udp, Addr, Port, Data},
      active_socket(Socket, Parent, Timeout);

    {error, Reason} ->
      Parent ! {error, socket, Reason},
      active_socket(Socket, Parent, Timeout)

end.

The multicast is a 45Mb RTP MPEG-TS stream. I am able to receive and verify the RTP sequence number successfully. However, about every Timeout period, in the function above, there are a number of datagrams dropped, that is, the RTP sequence number has a gap of about 200. This continues to happen as long as the process runs. Between the drops everything looks fine.

As you can see, my approach is to simply have a recvfrom pending at all times so when a datagram arrives the recvfrom returns, I forward the datagram and call recvfrom again. The Timeout is simply to avoid recvfrom returning with no data.

Thanks,

Mark.
signature.asc (application/pgp-signature, 528 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQEzBAEBCAAdFiEEYVHNuqOGsZElnxbO+5z0iCyWfG4FAmAcb3IACgkQ+5z0iCyW
fG4YFwf/W6Cz+O9GZCbO+K4J24jYfO/pEiN5sAaSpaEcAy9HvJOaigTJGVT1HTqF
y7/lmdBvcH1Jg4RSH+26FfNGY/3/L2SiIGO7cGnAxd0qp2dP3UjhWXP3osNDE3AP
yIsEEp0QdtxFaixiUArfFWHfGhGgU+DKZI3qCN0L3PLjWvaDPtbwTdgJn7dqlOw9
N1cCmJaOg6C3I/QR8HhvCd2pgqYUU62DhOO2r5olXO7g4aHJFvxfetcINwYZtfiP
tnLUXRKNbSzTz17Dzhof2PWL/oRgXsqQh/HJvms1TlZBZT+b8v+Qa4IKOXuMH1tu
Zt5eATo12+jDZ616S+lvB4ttg0Ftyg==
=ZLjt
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.