From: dd <dd...@gh...> - 2004-01-27 13:13:05
|
Why not just use IO::Socket and IO::Select? All my wx networking apps have a loop that looking something like the following. Gives good uniform results on all platforms I've tried. while(1) { my @ready = $select->can_read(0.01); while( $wxApp->Pending ) { $wxApp->Dispatch(); } foreach my $socket (@ready) { # handle socket data } } dd Peter van der Landen wrote: >>Il Tue, 20 Jan 2004 22:16:37 +0100 (CET) Peter van der Landen >><lan...@fr...> ha scritto: >> >> Hello, >> >> >>>One of my applications was using code copied from wxSocketServer to >>>handle >>>large numbers of TCP connections. It crashed regularly. When taking >>>one >>>connection per second it would predictably crash on the 1024th >>>connection >>>(that's just over 17 minutes runtime). >>> >>>When flooded with connections it would crash much quicker. >>> >>>To rule out any of the usual stupid mistakes on my part I went back to >>>running the wxSocketServer.pl demo code and attacked it with the >>>following >>>client: >>> >>>use IO::Socket; >>> >>>for (1..2048) { >>> print "Try $_\n"; >>> my $socket=IO::Socket::INET->new("localhost:5050"); >>> $socket->send( "Hello\n" ); >>> close($socket); >>>} >> >> Thanks! >> >> >>>Running this code will reliably crash the server demo within 10 >>>connections on my system. Inserting a sleep(1) in the loop helps a bit >>>but >>>then it just goes back to crashing after 1024 iterations. >>> >>>I changed my app to using UDP (which is better in my case anyway) but >>>using IO::Socket/Select within a timer handler doesn't seem right >>>(although it works). Is there any way to use UDP from wx? I found a >>>reference to wxSOCKET_DATAGRAM in the source. Does that do anything >>>yet? >> >> It is not officially supported in wxWindows (marked as alpha code), >>but there are some people using it. It will be wrapped for the next >>release. >> >> >>>How do I use it? How many packets will it handle before it crashes? >>>;-) >> >> As many as you wish, provided you don't create more than 1024 sockets >>:-) >>The problem is that wxSocketBase::Destroy is not wrapped, and simply >>calling close does not destroy the underlying socket -> socket handle >>exaustion. >> The ->Destroy method will be added in the next release. > > > I get it. But does that also explain the fact that when I leave out the > sleep(1) instruction the demo will crash in much less than 1024 > connections? > > Regards, > Peter > > > > > > ------------------------------------------------------- > 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 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users > |