seems better :-)
 
no account
 
you did the work... I'm just a tourist
 
 
 
 
 
 
 
 
 
 
 
 

I just looked at the code and I suggest this:
case yaws:outh_get_doclose() of
  true -> ok;
  false ->
    if
     GS#gs.ssl == nossl ->
      gen_tcp:close(Client);
    GS#gs.ssl == ssl ->
      ssl:close(Client)
    end
end

Along with:
  put(outh, (get(outh))#outh{doclose = false})
instead of
  put(websocket,true)

That should make it generic enough for usage in streaming pids.

wde, do you me to submit a patch with that code in github/do you have an account?

2009/12/18 wde <wde@free.fr>
ok seems to work
 
I just set a variable in the process registry in order to prevent yaws to close the socket.
 
In yaws_websockets:handshake/3 :
 
I set the registry key "websocket" just before sending the (web)socket to the owner pid  :
 
case TakeOverResult of
    ok ->
     put(websocket,true),
     ContentPid ! {ok, CliSock};
    {error, Reason} ->
     ContentPid ! discard,
     exit({websocket, Reason})
   end
 
...
 
always finish by exit(normal)  (catched in the acceptor0 function in yaws_server)
 

In the function acceptor0/2 in yaws_server , test the value of the registry key before to close socket :
 
...
 
Res = (catch aloop(Client, GS, 0)),
WS = get(websocket),
if
WS == true ->
ok;
GS#gs.ssl == nossl ->
gen_tcp:close(Client);
GS#gs.ssl == ssl ->
ssl:close(Client)
end,
 
 
this "hack" works for me
 
 
 

Your code seems good for me davide (but I'm not a guru)
 
Maybe in order to prevent yaws to close the socket, in yaws_server.erl we have to do something in the acceptor0 function
 
I will reuse your code (better than mine) and try to do it
 
thanks
 
 
 
 
 
 
 
 
 

Hi again,

Both wde and me have stumbled in a strange behaviour: even after passing control over the socket to the new owner (I've checked that it succeeds in doing so) the Yaws process is still able to close the socket - taking away all the funin web socketing. :\

Additionally, I should notice that my ewgi code only seems to work on mochiweb, the same issue pops up on ewgi_yaws and ewgi_inets. In both cases, simply delaying the "killing" of the server process seems to be enough to have the web socket open/working.

My current assumption is that it is possible for another process that is not the socket owner to close it. Can anyone share some insights into this?

Now excuse me while I go fire my test monkey. :)

Cheers,
Davide :)