Multi-threaded TCP redirection (proxy)

Berry-tan

Member
Joined
Dec 14, 2006
Messages
13
Location
Raleigh, NC, USA
Programming Experience
1-3
I'm writing an HTTP proxy server program. It's multi-threaded and the server part (where the local computer accepts a TCP connection and gets the server name and headers) works fine. It reads the headers, builds a new header, and sets it up to be sent. From there, all the proxy needs to do is forward data from the local computer going to the proxy to the remote server, and data coming from the remote server back going to the proxy to the local computer.

Basically, the data flow for the TCP redirector should look like this:
  • Local computer → Proxy → Remote server
  • Remote server ← Proxy ← Local computer
(The local computer might send no data, and vice versa; so switching between synchronous Read and Write methods wouldn't suffice)

Unfortunately, that's where I'm stuck. There aren't any good examples or tutorials on how to handle asynchronous network streams. I'd like to have an object that triggers an event when data is received from a socket. Anyone have experience with the NetworkStream class?

Edit: I've attached the user class in a .ZIP file.
 

Attachments

  • ProxyServer.zip
    16.2 KB · Views: 89
Last edited:
.NET Proxy

hey,

i have been attempting the same and i think i have got a little further. I seem to get intermittent results. I get images and pages and can even stream mp3s but get errors thrown up intermitently and i cant track down why.

I was planning on starting an open source vb.net proxy project much like squid. It seems that windows is lacking some good open source software.

Have you gotten any further with yours? Maybe we can help eachother along?

you can reach me direct at stevenhunt_@hotmail.com
 
Back
Top