在windows 上php 運行 daemon

edited 一月 2014 in 進階PHP討論
我想要將一個用php 寫的bot注冊成類似linux 上的daemon 可以什樣做???
因為如果不用background 程序要花上50% cpu (q8400s) 4核當然是有點舊
<?php



set_time_limit(0);
 

$socket = fsockopen("irc.justin.tv", 6667);
 

fputs($socket,"USER ccuuttww\n");

fputs($socket,"PASS oauth:xxxxxxxxxxxxxx\n");
fputs($socket,"NICK ccuuttww\n");

fputs($socket,"JOIN #channel\n");

while(1) {
 
	// Continue the rest of the script here
	while($data = fgets($socket, 128)) {
 
echo nl2br($data);
		flush();
$pos=strpos($data,":",2);
$command=substr($data,$pos+1);
$command=trim($command);
if(strcmp($command,"-message")==0)
{
fputs($socket,"PRIVMSG #channel : message\n");

}

	}
 
}


?>
bot 的初面貌

評論

Sign In or Register to comment.