From: Graciliano M. P. \(V. Sites\) <gm...@vi...> - 2003-01-05 22:04:14
|
Mattia, I saw in the TODO of wxPerl the line: wxSocket* ? Well, I had think "why wrappe wxSocket if Perl already have Sockets", until try to use Perl Sockets with Wx. Is just impossible to use them together, specially on Win32. I try to make an app that open a socket and write in some TextCtrl each line received in the socket AND send through the Socket lines writed in other TextCtrl, making a Talk program. The problems: 1* I can't read all the time the Socket, since it's from Perl, and we stop the Wx app if we stay inside a loop on Perl subs. To avoid this I make the program read the Socket from a wxTimer every 1s. But to never break Wx I need to make first a IO::Select in the Socket, or we stop (freeze) until receive data. 2* IO::Select doesn't work with Wx, at least on Win32!!! Yes, since IO::Socket use a interface similar to sleep() to wait for the data, and sleep() doesn't work when Wx is loaded on Win32, we can't make a IO::Select, since it always say that the Socket doesn't have data in the buffer when Wx is loaded! 3* Read a Socket from a Perl function can make some conflicts with other events of Wx, since we are always running a Perl sub. Imagine if you want to read 2+ Sockets! 4* If I want to read and send data through the Socket I really need to use IO::Socket! Or I only can send data after read something! The concept of Socket for GUI interface are different of Perl Sockets. I think that wxSocket will be useful, since we can work with events to get connections and data. And the Accept(), like other functions, can be used without block the GUI. Regards, Graciliano M. P. |