[erlang-questions] Can gen_tcp/inets store connection-specific user state?

Tony Rogvall tony@REDACTED
Tue Jul 20 00:48:26 CEST 2010


Why not use a global ets table? (use socket/port as a key)
If you would attach any kind of data to a socket you would have to copy it any how...
(There is a hidden way of doing it, but it's already taken by inet ;-)

/Tony


On 19 jul 2010, at 19.51, Tony Arcieri wrote:

> On Fri, Jul 16, 2010 at 6:41 AM, Juan Jose Comellas <juanjo@REDACTED>wrote:
> 
>> The beauty of Erlang is precisely that you don't have to worry about this.
> 
> 
> That seems to be a common reaction when I pose a question in this manner.  I
> would suggest that round tripping lots of explicit state is very much the
> norm of Erlang, and while that's a bit ugly IMO, here I'm running into a
> case where I'd like to do it where it isn't possible.
> 
> Why are you worried about having one Erlang process per connection?
>> 
> 
> I already spelled that out in my previous email, but beyond that, they are
> unneeded in this case and add additional overhead.  The requirement to use a
> process is imposed only by the design of the gen_tcp/inets APIs.
> 
> It seems like attaching a single piece of immutable state to each connection
> is going to add a lot of complexity.  In order to expose a sequential,
> side-effect based API to the end user, I'm going to have to proxy all
> communication between inets and the end user, and also provide process
> management.
> 
> Let's just say I consider this an unparsimonious and inelegant solution with
> more overhead than leveraging the end-to-end potential for associating
> connection specific state with particular sockets.
> 
> -- 
> Tony Arcieri
> Medioh! A Kudelski Brand



More information about the erlang-questions mailing list