flash socket policy-file-request in Erlang

This Erlang version is pretty much a straight translation of this perl-flavoured socket policy file to give credit where it’s due

-module(fs_auth).
-export([start/0]).
start() ->
    {ok, Listen} = gen_tcp:listen(843, [binary,{reuseaddr, true}, {active, true}]),
    spawn(fun()-> connect(Listen) end).

connect(Listen)->
    {ok, Socket} = gen_tcp:accept(Listen),
    spawn(fun()-> connect(Listen) end),
    loop(Socket).

loop(Socket)->
    receive
        {tcp, Socket, <<"<policy-file-request/>", 0>>} ->
            Reply = <<"<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>", 0>>,
            gen_tcp:send(Socket, Reply),
            loop(Socket);
        {tcp, closed, Socket}->
            io:format("server closed socket")
    end.



coded by nessus