Hi dd,
I'm already using IO::Socket and IO::Select at the moment, but I'm using a
timer to check the select handle every 0.01 second. I'm just not sure if
this is such a good idea, since the checks create a load on the CPU (4%)
Nope, using an alarm/timer isn't a good idea. The entire point of
select is todo this for you.
even when the app is not doing anything. (I tried your solution with the
same resulting load)
Loads will vary based on operating system and how long your timeout is
(IO::Select is an interface into the unix select call).
Also I think my timer solution adds latency in the handling of incoming
network data but I think yours would probably add latency in the GUI
interface. (I think you insert a 1/100 delay in the programs idle loop).
I haven't seen any latency in the gui from a loop like this. There is
always going to be some added delay to handle things (even if you are
performing event based networking). 1/100 delay is never really going to
be noticable since most events are user generated (mouse clicks, window
moving). In the event that a major # of events start occuring (dragging
window's around), there will be some latency in reading data, but not in
ui (this is due to handling all messages before moving on).
Anyway I'm pretty new to this stuff, so if anyone could shed some light on
this or point out any errors in my thinking it would be most welcome. So
far wxPerl seems a great way to leverage my Perl skills to creating
Windows apps, so I'm happy I found you guys ;-)
The only real generic benefit I have seen for using event based is
around code consistency. If one is targetting a specific operating
system then there can be performance benefits in one type of solution
(e.g. windows has a callback and messaging model in there winsock
implementation).
I haven't looked at the wx code to see how there sockets stuff is
implemented on different platforms. I also tend to prefer the native
networking interfaces in perl since they have been around for so long.
You know they will work as expected with good performance on any platform.
dd
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|