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.

Monday, January 16, 2012

Coding megaphone_tcp

Previously...
  • I learned about parsing HTTP packets from a buffer.
  • I resolved to use a single process to respond to ejabberd_http.
  • I did an analysis of the event sequence that should take place in order to use a single process.

I started coding up the part of megaphone_tcp that is invoked when a connection is first received.  This part of the system actually does not need to do much.  So it would make no sense to put off doing it.

Totally.

Sigh.

Much of megaphone_tcp is copied from megaphone and megaphone_socket.  OK, I haven't displayed all of those files but if I had and then I displayed megaphone_tcp people would be like "Gee, that looks familiar!"  The steps to processing a segment are:
  • Determine if segment contains a complete header
    • If not, then keep reading until you do have a complete header
  • Parse out the connection ID and packet length, 
  • If you have a complete header, then determine if you have a complete megaphone packet
    • If not, then keep reading until you have a complete megaphone packet
  • Send the megaphone process the completed packet.
  • Wait for another packet to arrive.
Pretty straightforward, right?  So why haven't you finished yet?!!  Oh...I'm the one who's writing this.

Sigh.


No comments:

Post a Comment