CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Win32::GUI/IO::Socket problems



Jun 15, 2007, 9:59 PM

Post #1 of 4 (620 views)
Win32::GUI/IO::Socket problems Can't Post

This has been very frustrating...

I have been programming a Win32::GUI chat client and forking it to read/append and write at the same time. I was sure that it would work, however when I enter into a reading loop from the socket the entire program freezes up. I thought it might be a problem with fork, but when I subed it with a text file instead of a socket, it worked fine. This lead me to believe that it was a problem with the socket and the GUI, but something doesn't seem right, because when I don't fork and just send data through the socket there is no freezing. So what might be the problem?

Here is a quick example script I made:

  use Win32::GUI;  
use IO::Socket; my $PORT = 2000; print "HOST: ";
chomp(my $host = <STDIN>);
print "\n";

my $window = Win32::GUI::Window -> new (-name => "Chat_Box", -text => "Chat Box", -width => 550, -height => 700, -left =>

400, -top => 200);
-name => "Message",
-left => 85,
-top => 69,
-width => 300,
-height => 140,
-multiline=> 1);

-name => "SendText",
-text => "<<SEND>>",
-left => 150,
-top => 250,
-width => 100,
-height => 50);

-name => "ViewChat",
-left => 20,
-top => 400,
-width => 500,
-height => 240,
-multiline=> 1,
-readonly => 1);

my $client_socket = IO::Socket::INET -> new("$host:$PORT") or die "ERROR WITH CONNECTION\n";
$window->ViewChat->Append("CONNECTED TO $host");
$window->Message->Append("Your Message Goes Here.....");

sub start_chat
$pid = fork();

sub SendText_Click
my $some_text = $window->Message->Text();
print $client_socket "$some_text\n";
sub send_chat
sub recv_chat
$socket = shift;
$data = <$socket>;

(This post was edited by some_random_kid on Jun 15, 2007, 10:05 PM)


Jun 17, 2007, 11:47 PM

Post #2 of 4 (609 views)
Re: [some_random_kid] Win32::GUI/IO::Socket problems [In reply to] Can't Post

Well, I still cant figure this out. But I didn't realize that because perl runs very fast when in multiple self contained programs, that I could of just created multiple servers (like one on port 2000 and one on port 2001). The first will fork the clients and recv, while the second will fork and send. Each "Client" will infact be two clients and the royal servers will share information using a text file(which will also log). I tested it and it's very fast because each program is small. I guess the main problem was that when the forked process used the same handle at the same time they freeze. So creating two clients instead of one created two entirely different handles. However, even having success, it's still not what I want, because now I have to deal with twice as much maintance and twice as much security. This will only be my temporary 1.0 client. I still would like help trying to make the single client version (1.1).


Jun 18, 2007, 10:32 PM

Post #3 of 4 (599 views)
Re: [some_random_kid] Win32::GUI/IO::Socket problems [In reply to] Can't Post

Does anyone ever reply on this forum??????


Jun 19, 2007, 12:07 AM

Post #4 of 4 (597 views)
Re: [some_random_kid] Win32::GUI/IO::Socket problems [In reply to] Can't Post

I am about the only regular member of this forum that answers questions. But I have no clue how to answer your question. I suggest you try asking at where there is a larger group of active and experienced perl coders.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives