rendered paste body<?php
set_time_limit(0);
$address = 'irc.devcollective.com';
$port = 6667;
$nick = 'darksbot-0';
$name = 'darksbot';
$chan = "#devcol";
$botCount = 5;
$botSockets = array();
for ($i=0; $i<$botCount; $i++)
$botSockets[$i] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
foreach($botSockets as $socket)
{
socket_connect($socket, $address, $port);
// Add error checking here to see if connection was successful!
socket_write($socket, "NICK ".$nick);
socket_write($socket, "USER ".$name.' '.$name.' '.$address.' :'.$name);
}
while (true)
{
// Duplicate the socket array to avoid losing the array of sockets.
$read = $botSockets;
// A polling delay is REQUIRED
$select = socket_select($read, $write=null, $exp=null, 0, 50);
if (false === $select) {
echo "socket_select() failed, reason: " .
socket_strerror(socket_last_error()) . "\n";
}
else if ($select > 0) {
foreach($read as $socket)
{
// Execute your socket reading here
}
}
}
?>