What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Saturday, January 7, 2012

The Next Problem

Previously...
  • I identified how to put a new module into the system.
  • I experimented with creating a new module.
  • I added the new module to the system (after troubleshooting a problem).
At this point, megaphone seems to start up when something tries to connect to the server, but the connection closes immediately.  For the code:

gen_tcp:recv(Socket, 0)

I was getting the result:

{error, closed}

Poking about on the net a bit came up with this article:


Long story short, the calling erlang process was terminating, which automagically closes all TCP connections associated with it.  The solution was to call:

gen_tcp:controlling_process(Socket, Pid)

Which tells erlang that the process associated with the socket is something different from what it was originally using.

Next step, everything will work.

Magically.

Really.

No comments:

Post a Comment