When I go to the advanced settings in Firefox I find a place for configuring it to communicate through proxy server. I thought it would be a simple straight forward thing to write a program for this.
I have to instances of Winsock object. One I call Server and it receives HTTP requests from the browser, parses the HTTP request header to get the destination host address, then commands the Client (the other Winsock on my form) to connect to that site and wait until it is ready before sending, at which point it sends the entire HTTP packet to the destination host. The client is simply programmed to receive HTTP replies (all the HTML etc) from the destination address, and then trigger the server Winsock to relay this data back to the browser when the server is ready (it waits for the server to be ready if the server is already doing sending data to the browser before sending the next packet).
It's fine in theory. And all my code looks right, but there's one problem. It's VERY flaky in actual operation. Sometimes some pictures will load on a page but others won't. Sometimes the page will load half way, and then stop altogether, leaving everything below a certain point completely blank.
I think the problem is in overlapping packets.
If they overlap, I can do one of 3 things. If while my proxy's client component is relaying a previous packet from the browser a new packet from the browser is received by the proxy's server, I have 3 thinks I can do:
1. cease transmission of the current packet and start the new one
2. keep sending the old one and ignore the new one
3. try to keep a que of browser's requests to the website
These options also apply to overlapping packets coming from the website. The first 2 options will lose some data so the website won't load properly. The 3rd option is so complicated that though I've tried it countless times I can't get it to work at all.
Another big problem is when different things are stored on different hosts (main HTML, images, cookies, ad banners, other resources) for any one website. So I have to keep track of packets going to and from the website, often at multiple different domains even for just one site. And problems can be even worse if parsing the header (in order to get the host address to send the packet to the right destination) takes too long and more data is attempted to be transfered while my program is still running the header parser routine for a 10-packet old packet of data (these packets can be spaced MICROSECONDS APART fired like an ultrafast machinegun, shorter than the 1 to 10 milliseconds it takes to parse a header even, as VB6 code is notoriously slow compared to assembly, or even C or C++). This gets the requests and corresponding responses packets out of sync (which they must be in synch time wise if they are to work properly). And things get even trickier with cookies, webserver response packets that aren't tied to any specific browser request.
As such, a proxy for firefox seems just beyond the reach of VB6 programming. If I'm mistaken, and what I want is in fact possible to write this in VB6, please help me to write a web browsing proxy for Firefox using VB6.
I have to instances of Winsock object. One I call Server and it receives HTTP requests from the browser, parses the HTTP request header to get the destination host address, then commands the Client (the other Winsock on my form) to connect to that site and wait until it is ready before sending, at which point it sends the entire HTTP packet to the destination host. The client is simply programmed to receive HTTP replies (all the HTML etc) from the destination address, and then trigger the server Winsock to relay this data back to the browser when the server is ready (it waits for the server to be ready if the server is already doing sending data to the browser before sending the next packet).
It's fine in theory. And all my code looks right, but there's one problem. It's VERY flaky in actual operation. Sometimes some pictures will load on a page but others won't. Sometimes the page will load half way, and then stop altogether, leaving everything below a certain point completely blank.
I think the problem is in overlapping packets.
If they overlap, I can do one of 3 things. If while my proxy's client component is relaying a previous packet from the browser a new packet from the browser is received by the proxy's server, I have 3 thinks I can do:
1. cease transmission of the current packet and start the new one
2. keep sending the old one and ignore the new one
3. try to keep a que of browser's requests to the website
These options also apply to overlapping packets coming from the website. The first 2 options will lose some data so the website won't load properly. The 3rd option is so complicated that though I've tried it countless times I can't get it to work at all.
Another big problem is when different things are stored on different hosts (main HTML, images, cookies, ad banners, other resources) for any one website. So I have to keep track of packets going to and from the website, often at multiple different domains even for just one site. And problems can be even worse if parsing the header (in order to get the host address to send the packet to the right destination) takes too long and more data is attempted to be transfered while my program is still running the header parser routine for a 10-packet old packet of data (these packets can be spaced MICROSECONDS APART fired like an ultrafast machinegun, shorter than the 1 to 10 milliseconds it takes to parse a header even, as VB6 code is notoriously slow compared to assembly, or even C or C++). This gets the requests and corresponding responses packets out of sync (which they must be in synch time wise if they are to work properly). And things get even trickier with cookies, webserver response packets that aren't tied to any specific browser request.
As such, a proxy for firefox seems just beyond the reach of VB6 programming. If I'm mistaken, and what I want is in fact possible to write this in VB6, please help me to write a web browsing proxy for Firefox using VB6.