#StackBounty: #php #windows #proxy #irc #fsockopen How to use fsockopen (or compatible) with SOCKS proxies in PHP?

Bounty: 50

I’ve coded a non-evil, non-spammy IRC bot in PHP, using fsockopen and related functions. It works. However, the problem is that I need to support proxies (preferably SOCKS5, but HTTP is also OK if that is somehow easier, which I doubt). This is not supported by fsockopen.

I’ve gone through all search results for “PHP fsockopen proxy” and related queries. I know of all the things that don’t work, so please don’t link to one of them.

The PHP manual page for fsockopen mentions the function stream_socket_client() as

similar but provides a richer set of options, including non-blocking connection and the ability to provide a stream context.

This sounded promising at first, supposedly allowing me to just replace the fsockopen call with stream_socket_client and specify a proxy, maybe via a “stream context”… but it doesn’t. Or does it? I’m very confused by the manual.

Please note that it must be a PHP code solution; I cannot pay for “Proxifier” or use any other external software to “wrap around” this.

All the things I’ve tried seem to always result in me getting a bunch of empty output from the server, and then the socket is forcefully closed. Note that the proxy I’m trying with works when I use HexChat (a normal IRC client), with the same network, so it’s not the proxies themselves that are at fault.

Get this bounty!!!