Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 26652 invoked from network); 1 Mar 2010 08:57:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Mar 2010 08:57:55 -0000 Received: (qmail 62890 invoked by uid 500); 1 Mar 2010 08:57:54 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 62779 invoked by uid 500); 1 Mar 2010 08:57:53 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 62762 invoked by uid 99); 1 Mar 2010 08:57:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Mar 2010 08:57:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alexander.farber@gmail.com designates 74.125.82.173 as permitted sender) Received: from [74.125.82.173] (HELO mail-wy0-f173.google.com) (74.125.82.173) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Mar 2010 08:57:43 +0000 Received: by wyb36 with SMTP id 36so1140458wyb.18 for ; Mon, 01 Mar 2010 00:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=qMViDeThhyBTECcFCCbWAvC61zik2RvyAfnh6bBeZhY=; b=PytnK2+EHFdFbg39W1S2Bx73V7tIoHeNs/HNvXuiJocEqCS9XQuiFCXQ+God4eypyC MXMG8NWI4B5oogvpZJX8umdvmcFfUnXU53g9tX7SACqoFisNiQRuDu27/Nn5X4P3+KWx rkKg83cfp6KKorSokZNt59cipw2LeP3jQaZFA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=EFLV344lkByS1eKBoTPUHPUzCBWjTB2agTcg8/OGvfhFV7HZPiiWscJ3u2lruIvPTF oo9ujU0JqZNpNNoJYlUq3w15lxNJBzkyAq4wXyQsD/XiNEB/idocOnAiy/X9xSl1h9gE 1WUrHy8TY1alb4AO8hSQt3DDdFbBHch4hzkfQ= MIME-Version: 1.0 Received: by 10.216.88.212 with SMTP id a62mr2793007wef.72.1267433841299; Mon, 01 Mar 2010 00:57:21 -0800 (PST) Date: Mon, 1 Mar 2010 09:57:21 +0100 Message-ID: <943abd911003010057w43194d28k4c4c6bad8709b14a@mail.gmail.com> Subject: HTTP Streaming with Apache 1 From: Alexander Farber To: modules-dev@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hello, I have a game, a daemon listening at port 8080 for TCP clients. The clients send auth. details with each their message and I keep the state, so the TCP-connection can be interrupted and then reconnected and the game will still continue. To support players behind corporate firewalls :-) I've written a simple Apache module, which will listen for client requests at the port 80, then read that POST request in, then connect to port 8080 and forward that data. Then it will stay connected to both ports and forward data from the game daemon to the web client: I want it to stay connected and "stream HTTP data" back, so that I can update the web clients instantly, when something changes. Perfect solution would be to poll() at the both sockets (80 and 8080) and forward the data in both directions. But unfortunately this isn't possible with Apache 1 (would it work with Apache 2? Can I get ahold of the client socket there and can I poll() it?) So I try the other trick: when the web client needs to send a new asynchronous message to the game daemon, I cancel the previous connection (unfortunately the Apache module doesn't notice that, because it is blocking while reading from the port 8080 socket) and also in the game daemon I take the notice, that a new message has arrived from the same user and close the port 8080 socket to the old Apache module. Unfortunately this works only few times and then I hit the max. children limitation of Apache (I've set it to 10 at my debug server) and Apache refuses to accept further connections. I'm using Apache 1.3.x of OpenBSD 4.5 and the source code of my Apache module is at http://pastebin.com/FvnXieN7 Does anybody have any good comments? Thank you Alex PS: And my (Russian card) game is at http://apps.facebook.com/video-preferans/ :-)