[erlang-questions] Sending UDP packets

Attila Rajmund Nohl attila.r.nohl@REDACTED
Fri Aug 21 19:31:12 CEST 2015


Hello!

Check the traffic on the network using wireshark or a similar tool and
see what data is sent and in how many packets.

2015-08-21 14:15 GMT+02:00 Oscar Muñoz Garrigós <osmuogar@REDACTED>:
> Hi,
> I am using a server to send some packets. The problem is actually the
> packets are truncated and my client does not receive the full packet. I
> created two sockets but only the socket wich receives the packet returns it
> to the client, if i change it the packet is lost. Could you give me some
> advice?
>
> Here is the code:
>
>
>
> -behaviour(gen_server).
> init(_Args)->
>     ...
>     {ok,Socket} = gen_udp:open(49900),
>     {ok, #state{socket=Socket}}.
>
> handle_info(Info, State)->
>     error_logger:info_msg("Received via INFO: ~p~n", [Info]),
>     {udp, Socket, IP, InPortNo, Packet} = Info,
>     [{"from",From},{"to",To},{"text",Text}] = parser:read_xml(Packet),
>
>     write_to_db(Socket, IP, InPortNo, From, To, Text),
>     {noreply, State}.
>
> write_to_db(WSocket, WAdress, WMPort, WFrom, WTo, WText)->
>      ...
>      ...
>     Message = analizar_resultados(Respuesta),
>
>     {ok, SSocket} = gen_udp:open(0,[inet]),
>     %%ok = gen_udp:send(SSocket, WAdress, WMPort, Message), <-------- This
> does not works cause the packet is lost
>     ok = gen_udp:send(WSocket, WAdress, WMPort, Message), <-------- This
> works but the packet is truncated
>     gen_udp:close(SSocket),
>     ok.
>
>
>
>
>
> Thank you all for your help.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list