Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class irc{
- function __construct($se = array()){
- foreach($se as $s){
- if(!isset($s['channels'])){
- $s['channels'] = array();
- }
- $this->addServer($s['server'],$s['port'],$s['nick'],$s['name'],$s['channels']);
- }
- $this->wait();
- }
- function wait(){
- foreach($this->servers as $pid){
- pcntl_waitpid($pid,$status);
- }
- }
- function addServer($se,$po,$ni,$na,$cha = array()){
- if(!$this->child){
- $pid = pcntl_fork();
- $this->servers[] = $pid;
- if ($pid == -1) {
- die('could not fork');
- } else if ($pid) {
- } else {
- $this->child = true;
- // we are the child
- $s = new server($se,$po,$ni,$na,$cha);
- $s->recieve();
- }
- }
- }
- private $servers;
- private $child = false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement