PHP Warning: socket_sendto(): unable to write to socket [0]: A request to send or receive data was disallowed because the socket is not connected and (when sen ding on a datagram socket using a sendto call) no address was supplied. in C:\Program Files\php\bot.php on line 17 botSockets as $socketId => $source) { socket_write($this->botSockets[$socketId], $dataSend."\n\r"); echo "---> $dataSend
"; } } else { socket_write($this->botSockets[$botNumber], $dataSend."\n\r"); echo "---> $dataSend
"; } } function botSocketCreate($botCount) { for ($i=0; $i<$botCount; $i++) { $botInfo = array($i => array("nick" => "DarkBots-".$i, "name" => "poopymanname", "chan" => "#devcol")); $this->botSockets[$i] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); } } function sendInfo() { foreach($this->botSockets as $id => $socket) { socket_connect($this->botSockets[$id],$this->address, $this->port); // Add error checking here to see if connection was successful! $this->dataSend("all", "NICK ".$this->nick.$id); $this->dataSend("all", "USER ".$this->name.$id.' '.$this->name.$id.' '.$this->address.rand(1,100).' :'.$this->name.rand(1,100)); } } function receiveData() { while (true) { // Duplicate the socket array to avoid losing the array of sockets. $read = $this->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 => $k) { $data = socket_read($k,2048); $ex = explode(" ", $data); echo $ex[0]; if ($ex[0] == "PING") { $pong = $ex[1]; echo $pong; $this->dataSend("all", "PONG $pong"); $this->dataSend("all", "JOIN $chan"); } echo $data; } } } } } $class = new mainIrcBot(); $class->botSocketCreate(10); $class->sendInfo(); $class->receiveData(); ?>