How does the proxy get to know the original destination IP address and port? By looking into the HTTP-request, perhaps? If so, what if the application protocol (some other than HTTP) does not contain the destination URL?
Use SO_ORIGINAL_DST, for example:
getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &dst_addr, &addrlen);
-- Philip Craig - philipc@xxxxxxxxxxxx - http://www.SnapGear.com SnapGear - Custom Embedded Solutions and Security Appliances