Hello I'm close. The problem is that the GUI will not open until the server gets a connection. The GUI should open first showing the IP of the computer, ready to receive commands, and show the command. Please help! Here's the code.....

#!/usr/bin/perl<br> package main;<br> use IO::Socket;<br> use Sys::Hostname;<br> use Socket;<br> use 5.008;<br> #use strict;<br> #use warnings;<br> my($ipaddr)=inet_ntoa((gethostbyname(hostname))[4]);<br> $| = 1;<br> my $app = Demo::App->new;<br> # create the WxApplication<br> #$self->SetSize($text->GetSizeWH);<br> $app->MainLoop;<br> package Demo::App;<br> #use strict;<br> #use warnings;<br> use base 'Wx::App';<br> sub OnInit {<br> my $frame = Demo::App::Frame->new;<br> $frame->Show(1);<br> }<br> package Demo::App::Frame;<br> #use strict;<br> #use warnings;<br> use Wx qw(:everything);<br> use base 'Wx::Frame';<br> sub new {<br> my ($class) = @_;<br> my $self = $class->SUPER::new(<br> undef, -1,<br> 'Demo::App',<br> wxDefaultPosition, wxDefaultSize,<br> );<br> my $text = Wx::StaticText->new( $self, -1, "For X10 Voice Commande +r Use IP $ipaddr\n Port 8086\n");<br> #sub serv {<br> $local = IO::Socket::INET->new(<br> Proto => 'tcp', # protocol<br> LocalAddr => "$ipaddr:8086", <br> ) or die "$!";<br> my $addr; <br> $local->listen(); <br> $local->autoflush(1); <br> while ($addr = $local->accept() ) { <br> print "Connection from: ", $addr->peerhost(),"\n"; <br> while (<$addr>) <br> { <br> $path = "C:/Program Files (x86)/Common Files/X10/Common";<br> chdir($path) or die "Cant chdir to $path $!";<br> ~s/GET//,~s/~/ /g,~s/%20/ /g,~s/%22/ /g,~s/x10command=DEVICE/ +/,~s/\//\ /g,~s/[?]//g ,~s/'/ /g,~s/HTTP/ /,~s/1.1/ /g,~s/sh://;<br> system(AHCMD. "$_");<br> print "Received: $_"; <br> print $addr $_; <br> print $path $_; <br> close $addr;<br> chomp;<br> return $self; <br> } <br> }<br> }<br>


In reply to Server with GUI by gg4000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.