Page 1 of 1

timing out of php irc script

Posted: Wed Apr 30, 2003 3:57 pm
by toms100
hmm
this script worked, it joined a channel then it quited after a few seconds (time out was too low)
but now after i changed a few things (just msgs) it takes for ever to connect, and then not much happens!
here is my entire script:

Code: Select all

<?php

set_time_limit(300);
class SimpleIRC {
	// variables
	var $username;/// bot username
	var $channel = "#cows";/// chanenl
	var $ij = "no"; /// init variable
	var $sockets;
	function checkpong($words) {
  		if($words[0] == 'PING') {
    		socket_write($this->sockets, "PONG ".$words[1]."\n");    
  			}
		}
	function initjoin() {
		if ($this->ij = "yes") {
			/// allrdy init
		}
		else {
			socket_write($this->sockets,"NICK ".$this->username." \r\n"); // Change our nickname 
			socket_write($this->sockets,"JOIN ".$this->channel." \r\n");
			socket_write($this->sockets,"PRIVMSG ".$this->channel." look this is c0ws scripit i wonder if it works\r\n"); 
			$this->ij = "yes"; 
		}
		}
 	function circ($server,$name) {
		$this->username = $name;
		echo "connecting...";
		$this->sockets = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
		socket_connect($this->sockets,$server,6667); 
		echo "connected";
		socket_write($this->sockets,"USER DAVE:RHAP\r\n");
	
	}
	function send_msg($msg) {
		socket_write($this->sockets,"MSG ".$this->channel." $msg \r\n"); 
	}

	function mainloop() {
	/// main loop of the class
	while($data = socket_read($this->sockets,4046)) // read whatever IRC is telling us 
		{ 
			echo $data."<br>";
			$words = explode(" ",$data);	
			$this->checkpong($words);
			$this->initjoin();
		} 
	
	}


}

$irc = new SimpleIRC;
$irc->circ("irc.netgamers.org","cbot");
$irc->mainloop();



?>
basically all that happens is it takes ages doing nothing, then
connecting...connectedNOTICE AUTH :*** Looking up your hostname
NOTICE AUTH :*** Checking Ident NOTICE AUTH :*** Couldn't look up your hostname NOTICE AUTH :*** Got ident response
Fatal error: Maximum execution time of 30 seconds exceeded in E:\evilmonkeh\irc\irc.php on line 39

is printed out..
before it coudl connect very fast and if there was a problem the problem would be shown instantly. now i dont know what is up :roll:

i would really appreciate if someone could help me:)

Tom

Posted: Wed Apr 30, 2003 4:46 pm
by volka
if your client cannot repsonse to identd-requests (port 113) some irc-nets refuse to let you enter.
You must also at least reply to PING-messages from the host or you risk to get disconnected.