Brian's Waste of Time

Sat, 31 Mar 2007

YAWS for Comet!?

Yesterday, Toby suggested that YAWS might be a great option for Comet. Poking through the YAWS docs I think he is right.

0 writebacks [/src/erlang] permanent link

Tue, 06 Mar 2007

Hello Reverser World!

With Joe Armstrong's new book, Programming Erlang, out in beta form I think I need to visit Erlang again. My first (and last) endeavor was a short and sweet reverser server:


handle_connection(ClientSock) ->
	case gen_tcp:recv(ClientSock, 0) of
		{ok, Stuff} ->
			gen_tcp:send(ClientSock, lists:reverse(Stuff)),
		{error, Reason} ->

server_accept(ServerSock) ->
	{ok, ClientSock} = gen_tcp:accept(ServerSock),
	Pid = spawn(fun() -> handle_connection(ClientSock) end),
	gen_tcp:controlling_process(ClientSock, Pid),

start(Port) ->
	{ok, ServerSock} = gen_tcp:listen(Port, [list, {active, false}]),
	spawn(fun() -> server_accept(ServerSock) end).

At the time I was very impressed with Erlang's available documentation -- I was able to make that from not knowing anything in just a couple hours, and it worked! O frabjous day!

I'm only about 50 or 60 pages into Joe's book, but those pages, at least, are extremely well written and make clear not only how to do things but what Erlang is actually doing under the covers (to some degree) which makes a world of difference.

0 writebacks [/src/erlang] permanent link