Had things happen with Tk, had things happen with Wx.
I'm back to the start. Wx.The window opens after the server gets a connection. The Window has to open and display the IP First.
Then display the text from the client. And display the next set of text from the client.And send the commands to the computer. I'm still stuck with "What to do instead of While"
And a test client.....#!/usr/bin/perl package main; use IO::Socket; use Sys::Hostname; use Socket; use 5.008; #use strict; use Wx; use wxPerl::Constructors; use base 'Wx::App'; use Wx qw(wxTE_MULTILINE wxVERTICAL wxID_DEFAULT); #use warnings; my($ipaddr)=inet_ntoa((gethostbyname(hostname))[4]); $| = 1; my $app = Demo::App->new; $app->MainLoop; package Demo::App; #use strict; #use warnings; use base 'Wx::App'; sub OnInit { my $frame = Demo::App::Frame->new; $frame->Show(1); } package Demo::App::Frame; #use strict; #use warnings; use Wx qw(:everything); use base 'Wx::Frame'; sub new { #print "Ready for next command.\n\n"; my ($class) = @_; my $self = $class->SUPER::new( undef, -1, "X10 Voice Commander", wxDefaultPosition, wxDefaultSize, ); $self->{text} = Wx::TextCtrl->new($self, -1, "", [-1,-1], [300, 300], +wxTE_MULTILINE); $self->{text}->AppendText("Use Your IP $ipaddr:8087 on your devi +ce.\n"); #$self->{text}->AppendText("Connection from: ", $addr->peerhost(), +"\n"); #sub serv { $local = IO::Socket::INET->new( Proto => 'tcp', # protocol LocalAddr => "$ipaddr:8087", ) or die "$!"; my $addr; $local->listen(); $local->autoflush(1); while ($addr = $local->accept() ) { print "Connection from: ", $addr->peerhost(),"\n"; while (<$addr>) { $path = "C:/Program Files (x86)/Common Files/X10/Common"; chdir($path) or die "Cant chdir to $path $!"; ~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://; system(AHCMD. "$_"); print "Received: $_"; print $addr $_; print $path $_; close $addr; chomp; return $self; } } }
Run the server first. Type anything into the client. Commands are if you have X10 installed "A1 On"use IO::Socket; use Sys::Hostname; my($ipaddr)=inet_ntoa((gethostbyname(hostname))[4]); $remote = IO::Socket::INET->new( Proto => 'tcp', # protocol PeerAddr=> "$ipaddr:8087", PeerPort=> "8087", # port of server Reuse => 1, ) or die "$!"; print "Connected to ", $remote->peerhost, # Info message " on port: ", $remote->peerport, "\n"; $remote->autoflush(1); # Send immediately while (<>) { # Get input from STDIN print $remote " "; print $remote "sendplc "; print $remote $_; # Send to Server #last if m/^end/gi; # If 'end' then exit loop my $line = <$remote>; # Receive echo from server if ($line ne $_) { # If not the same as input #print "Error in sending output\n"; # error exit; # Terminate } print "End of client\n"; # End of client close $remote; # Close socket exit }
In reply to Re^4: Server with GUI
by gg4000
in thread Server with GUI
by gg4000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |