Search This Blog

Thursday, January 21, 2010

01-21-2010

Spent a couple hours on a con call about Remedy.  Started coding up the proxy that might get used on the Finesse integration project.  The proxy is proving to be a challenge and I think it might have to do with HTTP.  I've coded up a proxy server that accepts a connection and redirects it to www.google.com.  I have two threads for each redirect: one for the client-to-server stream and one for the server-to-client stream.  A couple observations: I usually don't see a thread complete -- which is supposed to happen when -1 is detected on the stream read.  The web pages don't always work.  I'm wondering if it is because I only redirect to www.google.com and no other site on the net.   Peeking at the byte stream to figure out the destination isn't very useful because I've introduced HTTP knowledge into the code.  As an experiment, I put in some code that checks for available bytes before reading.  If no data is available, we'll sleep and wait for some.  If we wake up and there is no data, we exit the loop.  That seems to be work better but feels like a hack.  Is HTTP keep-alive keeping the stream from closing?  According to some web page, in HTTP 1.1 all connections are keep-alive, which might explain why the streams never close.  I bet if I waited long enough, the browser would drop the connection.  I just don't have that kind of time.  My brain is full.  Going home.

No comments:

Post a Comment