in reply to Proxy Server Help
Good ol’ select() is probably your best friend here, and a relatively simple design. If you think about it, a proxy is always just doing one of three things: it’s processing a packet that has arrived; or it is processing a connect-request; or, it is snoozing, waiting for one of those other two things to happen. The amount of CPU-time required to deal with any of these eventualities is virtually non-existent. No matter how many “active connections” there might be, all of those are simply destinations. They don’t add to the actual workload, which simply consists of connect-requests and packets.
So, the app really isn’t “multi-threaded” at all. It’s a simple linear loop, executing in an entirely I/O-constrained fashion that, from the CPU’s point-of-view, isn’t even particularly “fast.” Like a dutiful mail-clerk, when a letter arrives, drop copies of it into the appropriate outbound slots, and when a connect request arrives, manufacture another slot. Rinse and repeat. Work for a few microseconds, then sleep for milliseconds.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Proxy Server Help
by PhillyR (Acolyte) on Aug 23, 2011 at 19:38 UTC |