Add TNS gateway

@ntalbott Made suggested changes.  This bit here where I supply the responses appears to be LIFO rather than FIFO.  It looks strange but I suppose it is OK.