gen_tcp:recv - last segement when closed port

jmT2 johan@REDACTED
Sun Mar 12 09:05:47 CET 2006


How does the gen_tcp:recv/2 work? It calls inet_db:lookup_socket/1 to see  
where tehsocket belongs or ....? I guess this is where it detects that the  
socket is closed? What happens in erlang:get_port_data/1? I guss the  
problem is in how WinSock is used.

   Johan


gen_tcp:--------------------

recv(S, Length) when port(S) ->
     case inet_db:lookup_socket(S) of
	{ok, Mod} ->
	    Mod:recv(S, Length);
	Error ->
	    Error
     end.


inet_db:---------------------

lookup_socket(Socket) when port(Socket) ->
     case catch erlang:port_get_data(Socket) of
	Module when atom(Module) ->
	    {ok, Module};
	_ ->
	    {error, closed}
     end.







-----------
Johan Montelius jmT2



More information about the erlang-questions mailing list