The protocol between FitNesse and Fit is reasonably complex.  Remember that all the Fit code runs in a completely different process, possibly in a completely different language.  

When you click the test button on a test page or a suite page, FitNesse needs to send the HTML for the test tables to FIT, FIT needs to run the tests and send the colorized HTML back to FitNesse so that it can be displayed.  The moment that you click the test button two things happen.  First FitNesse creates a session for the test.  Secondly it starts the FitServer command line process and passes it the session identifier along with the hostname and port number of FitNesse. 

For Java this command is ''FitServer''.  There are three arguments:{{{java FitServer host port ticket
  host -- The name or IP address of the computer running FitNesse
  port -- The number of the socket that FitNesse is listening on.
  ticket -- The unique identifier for the session.}}}.

FitServer (or the corresponding program in a differenr language) opens a connection to FitNesse and issues the following HTTP request. {{{GET /?responder=socketCatcher&ticket=<<ticket>> HTTP/1.1}}} This tells FitNesse which session the current socket is attached to.  FitNesse then sends the HTML for the test tables over that socket.  FitServer runs the tests and sends the colorized HTML back over the same socket. 

The protocol is character based.  Every block of characters is preceded by ten characters which are ASCII digits representing the decimal length of the block being sent.  A block with a length of zero consists only of the ten decimal digits which are all the character zero.  This block, named ZERO, has special meanings depending on the context.

Once FitNesse recieves the HttpRequest for the socketCatcher, it sends a ZERO block to FitServer to tell FitServer that the connection is live.  It then proceeds to send the HTML for every test page as a separate block.  If this is just a single page test, then only on block is sent.  If this is a suite, then one block per page is sent.  When the last page is sent FitNesse follows with a ZERO block.

The FitServer also sends blocks of colorized HTML using the same character based protocol.  A page of colorized HTML may be returned as one large block or as many small blocks.  At the end of each page, FitServer sends a ZERO block followed by four more ten digit numbers which contain the counts as follows: right, wrong, ignores, exceptions.  

   
