phergie/phergie — Issue #195: IPv4 is not used on all systems
Author: elazar
Created: 2011-11-08 14:26:44+00:00
State: open
Labels: Maintenance

https://github.com/phergie/phergie/blob/master/Phergie/Driver/Streams.php#L375

A combination of circumstances, one of which is no context options being specified here, can cause the local machine to choose IPv6 over IPv4, which can lead to issues with some networks. We need to allow IPv4 to be forced here, possibly via a protocol connection option. Actually forcing IPv4 can be done like so:

```php
$context = stream_context_create(array(
'socket' => array(
'bindto' => '#.#.#.#:0', // possible that 0.0.0.0 could be used here
)));
$this->socket = stream_socket_client('tcp://' . $server . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context);
```

"I *think* that Freenode sees ipv6 blocks as "1 subnet per client", so you can't circumvent their connection rules by using IPv6. But Linode assigns just 1 address per box. So if N people in the same subnet connect their box to freenode, then freenode says: hey, too many clients from the same person, I block. by using ipv4 you are guaranteed that only that server's connections are counted, so that allows you to connect, since then the number of connections would be less than N."