-- (c) William Welch 2004 -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; -- you must not claim that you wrote the original software. -- If you use this software in a product, an acknowledgment in -- the product documentation would be appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must -- not be misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source distribution. -- -- This license is commonly known as the zlib/libpng License. -- -- -- http.jal bvwelch 02 june 2004 -- revised for new tcp API, 5 April 2005 -- See RFC 2616 for details procedure http_task ( byte in conn_off ) is var byte stat , hi , lo var bit webstatus = true -- wait for someone to request a web page. stat = tcp_status ( conn_off ) if stat != 1 then return end if -- NOTE: we need to call tcp_recv, even though -- we don't actually care about the length of -- the request in our simple example. tcp_recv ( conn_off , hi , lo ) if MemRd ( TCP_APP_OFF ) != "G" then return end if -- init webpage offset MemWrEx ( FILE_CONN , conn_fileoffset_lo , 0 ) MemWrEx ( FILE_CONN , conn_fileoffset_hi , 0 ) -- send the page, using multiple packets. while webstatus loop -- at least one loop. webstatus = web_sector ( FILE_CONN , TCP_APP_OFF ) -- fill data if webstatus then -- true if more data pending hi = ( tcp_maxsegsize >> 8 ) -- tcp_maxsegsize lo = ( tcp_maxsegsize & 0x00FF ) else hi = MemRdEx ( FILE_CONN , conn_fileoffset_hi ) -- maybe less than tcp_maxsegsize bytes lo = MemRdEx ( FILE_CONN , conn_fileoffset_lo ) -- size in offset end if tcp_send ( conn_off , hi , lo ) -- must wait before sending the next page while tcp_status ( conn_off ) != 2 loop -- let the networking "stack" run. tcp_yield stat = tcp_status ( conn_off ) -- bailout/abort if user closes the web brower, -- or if someone tries a telnet session at this time. if stat > 0xf0 then return end if -- if browser sends a very verbose request for a page, -- we may get extra rx packets. just ignore them. if stat == 1 then tcp_recv ( conn_off , hi , lo ) end if end loop end loop tcp_send_close ( conn_off ) end procedure