Re: Yapircl vs PhpSmartIRC - comparison
| From: | Geir Torstein Kristiansen | Date: | Thu, 19 Dec 2002 03:37:38 +0000 |
| Subject: | Re: Yapircl vs PhpSmartIRC - comparison | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-11750@lists.php.net to get a copy of this message | ||
On Wednesday 18 December 2002 22:23, Mirco MEEBEY Bauer wrote:
> Geir Torstein Kristiansen wrote:
> > I believe that constructive discussion with real technical arguments can
> > be made. For example what is the pros & cons of X implementation of
> > feature Z compared to imlementation Y. I would be the first to admit that
> > my design/implementation of feature Z is suboptimal if I can be convinced
> > why another approach is better.
>
> If you want to do a constructive discussion, then we can do that. The
> first email sound like a Marketing Campaign from M$ :)
Most of the points raised were still valid apart from a few that I realize are
misleading. (I will try to explain below).
> > Im interested in how you plan to handle multiple connections in SmartIRC
> > for example.
>
> You mean 2 bots running from 1 script? If you mean that, I will not
> support that kinda thing, because PHP is already not the best choice for
> doing much socket and IRC stuff, the main problem is that it doesn't
> have any thread features, which makes is almost impossible for doing
> more than one connection with reasonable runtime speed.
> If you need 2 bots, do 2 seperate scripts using SmartIRC :)
There are a lot of single process irc clients out there which supports
multiple connections. I believe it can be done the same way in php by adding
more sockets to the select call. It is already possible to use several
connections with yapircl, check out yapgate.php in the examples dir. The only
thing is that in some places like during the connection it will block. What I
want to do is to try rewriting this like I stated in my original announcement
rant by adding some state information to each irc connection object.
> > I wrote correct me if I am wrong, which points? I never stated that this
> > was a neutral comparison, far from it.
> >
> > Im not sure what I overlooked here.
> ok here it comes :)
>
> -------------------------
>
> > It should be noted that SmartIRC is GPL while Yapircl is licenced
> > under the php license. But I would say from looking at the code that
> > they take a very different approach.
>
> Wrong, phpSmartIRCclass _is_ GPL, whats comming in PEAR is SmartIRC, its
> a modified and new release (PEAR version) of phpSmartIRCclass, and it
> is LGPL which is allright with PEAR. This was discussed on this mailinglist
How does the LGPL and the PHP license get along, can a PHP licenced project
reuse code from LGPL project or is it only the other way around. Any license
gurus? :)
> About the approach you are right, I read already some parts of your code
> and its completly different approach, but the goal/objective is almost
> the same.
>
> > What Yapircl has that SmartIRC has not:
> >
> > Normal message queue/Priority message queue
>
> Saying that SmartIRC doesn't has this, is wrong:
> It has a message queue, I am using a sendbuffer for that, but I don't
> have no real prorities, just: send the message _now_ or put it in queue
I was too eager to get the point across that yapircl has two different queues
I guess :)
> > Proper message throttling like IRCu, means it can first burst 5
> > messages then
> > 2 messages each second after that. Throttling can be turned off
> > temporary or permanently with setUseQ()
>
> Saying that SmartIRC doesn't has this, is wrong:
> I call that floodprotection, so the client doesn't get kicked from the
> server, SmartIRC also has it called senddelay() default is to send 2
> messages per second.
I didnt say it didnt have floodprotection, I said that it didnt have _proper_
flood protection which allows bursting of several messages in a row without a
delay before the 2 messages per second limit kicks in. Without the bursting
it feels less responsive in a channel if several commands comes in in rapid
succession.
> > YapirlBot class for looping a server list and reconnecting forever
> > with increasing timeouts if connecting is unsuccessfull.
>
> This will be included in the first SmartIRC release, in phpSmartIRCclass
> its not at the moment, its already on the official taskscheduler.
> See here:
>
> http://sourceforge.net/pm/task.php?group_project_id=24683&group_id=60664&fu
>nc=browse
>
> > Details about Yapircl mainloop/timersystem
> > If Yapircl is used to connect to one server only: It will call
> > socket_select()
> > with the time to the next timer expires as the usec argument so it
> > will sit idle until there is either socket activity or the timer
> > should run.
>
> same with phpSmartIRCclass
To be more specific one iteration of the idle loop in Yapircl will in this
case not return until the next timer is due or there is data on the socket.
SmartIRC will loop through _rawreceive() even if there is no data on the
socket because socket_select() will return after $this->_receivedelay*1000
usecs and will then proceed to check the buffer, loop through and checking
the whole timer list etc 10 times per second or so with the current default
setting. You might want to apply this idea from Yapircl if you want only to
support a single connection and want it to be optimized.
> > Win32 compatability
> > SmartIRC calls usleep() this will not work on win32 (Yapircl used to
> > do this too)
>
> eerrr, it _only_ does use the usleep() _if_ the php build has _no
> socket_ extension.
Ok, my mistake. I see this in the code now.
> I also allow running with older fsocks, which is for compatibibly better
> than Yapircl. Yapircl runs only with socket extension, if the php build
> doesn't has it, Yapircl cannot be used.
Earlier versions used fsockopen(). The support was removed because I could not
see a nice way to eventually make dcc support without the socket extension.
And I did not want to maintain both fsockopen() support and socket extension
stuff, especially since usleep() is not available on win32.
> About that usleep(), it will _not_ break anything, it will just be
> ignored without a "sleep" from windows, which results a higher CPU
> usage, because of running very fast through the loops without "stops"
> (only when using fsocks). So this is not a Win32 compatability problem.
> Just a performance thing on windooze, at least it will run on win32
> without socket extension, Yapircl not at all.
Well it runs in a grind loop with 100% cpu usage. I dont consider that usable
unless you want to stress test your cpu. The only workaround I know of is
sleep(1);
> > Correct me if I am wrong on any of these points. I am not familiar
> > with the SmartIRC code.
>
> I correct you, like you requested it :)
Yeah, and I was incorrect on some points. But in the end people now know more
about both projects.
> Whats more interessting is the goal of the IRC class, I don't know your,
> here is mine:
> An IRC API without knowing the IRC protocol at all, don't read a IRC RFC
> or whatever. That means no direct IRC calls at all.
> A good documentation for developers, understanding the easy API.
> The class can be used for IRC bots, webchats and also for getting IRC
> statistics and display it on a webpage (the last one I think is not so
> easy in Yapircl, with SmartIRC its 1 method call)
I would not let an irc bot connect to check the channel stats for every
pageview (unless the results was cached) but check the attached example.
> Clean and optimized code with 100% OOP, as much PHP allows me todo...
>
> So whats your main goal?
Main goal was originally to write an infobot. That goal has since expanded to
include dcc support, multiple connections and to serve as a foundation for
IRC bots and even a full featured ncurses or phpgtk based irc client. As you
I also want the code to be clean and the API to be easy (when this is
possible). And also the learning experience has been great so far.
> PS: about its good having "competition":
> "Competition" means both players will try to have all the features and
> pros of the other player plus more which will end in wrong directions....
Both projects might end up being more specialized to some specific task, we'll
see.
--
Geir Torstein Kristiansen
web: http://projects.gtk.mine.nu
<? /* * Example usage of the Yapircl class. The same as SmartIRC example2.php */ require_once '../Yapircl.php'; class Stats extends Yapircl { var $channel = "#yapircl"; function Stats() { $this->Yapircl(); } function event_connect() { $this->send('LIST ' . $this->channel); // $this->list($this->channel); // not wrapped yet, will be like this } function event_rpl_list() { if ($this->params[1] == $this->channel) { echo $this->params[2] . " users in " . $this->channel . "\n"; exit; // remove to make a clean quit (slower) } } } $stats =& new Stats; $stats->setDebug(false); $stats->setUser('stats', 'stats', 'Yet Another PHP IRC Library', '+i'); $stats->setServer('localhost'); $stats->connect(); $stats->run(); ?>
<? /* * Example usage of the Yapircl class. The same as SmartIRC example2.php */ require_once '../Yapircl.php'; class Stats extends Yapircl { var $channel = "#yapircl"; function Stats() { $this->Yapircl(); } function event_connect() { $this->send('LIST ' . $this->channel); // $this->list($this->channel); // not wrapped yet, will be like this } function event_rpl_list() { if ($this->params[1] == $this->channel) { echo $this->params[2] . " users in " . $this->channel . "\n"; exit; // remove to make a clean quit (slower) } } } $stats =& new Stats; $stats->setDebug(false); $stats->setUser('stats', 'stats', 'Yet Another PHP IRC Library', '+i'); $stats->setServer('localhost'); $stats->connect(); $stats->run(); ?>