rpt / gen_tcp_server

Generic TCP Server for Erlang applications
Apache License 2.0
11 stars 5 forks source link

Starting arguments for gen_tcp_server #2

Open useronym opened 9 years ago

useronym commented 9 years ago

Hi, would you be interested in making it possible to pass in arguments to the gen_tcp_server in gen_tcp_server:start_link? This would mean introducing a new 'init' callback. Currently we use a hardcoded solution which already works, so I won't go rewriting stuff if it's something you'd be against merging in. I would of course make sure to keep backward compatibility where possible.

Let me know what you think. Thanks for a great lib, by the way :)

rpt commented 9 years ago

Wouldn't it be enough to pass arguments (or initial state) to the _accept callback?

gen_tcp_server:start_link(Module, Port, Args, Options).
handle_accept(Socket, Args) -> {ok, State} | {stop, Reason}.
useronym commented 9 years ago

Ah yes, you're right, that would be better (it's our current solution, even). I'll clean it up and submit a pull request :)

By the way, I'm trying to get gen_tcp_server into the awesome-erlang bookmarks: https://github.com/drobakowski/awesome-erlang/pull/28

Cheers