S
steve
I have two routines, send tcp packet and receive tcp packet.
Rx packet is a Win32:GUI application.
Rx packet passes the packet contents to a subroutine to process the
contents, except the contents once they get to the sub is always
'SendMessage'???
if I put the subroutine in the main part things are OK with using
$buf.
any help would be great
Routines......
Rx-------------------------------
my $readable_handles = new IO::Select();
$readable_handles->add($main_sock);
while (1) {
Win32::GUI:oEvents();
( my $new_readable) = IO::Select->select($readable_handles, undef,
undef, 0);
foreach my $sock (@$new_readable) {
if ($sock == $main_sock) {
my $new_sock = $sock->accept();
$readable_handles->add($new_sock);
} else {
# It is an ordinary client socket, ready for reading.
my $buf = <$sock>;
if ($buf) {
print "buf - $buf\n"; <<<<<<<<<--------here is correct contents
RxMsg($buf);
} else {
# Client closed socket. We do the same here, and remove
# it from the readable_handles list
$readable_handles->remove($sock);
close($sock);
}
}
}
}
}
sub RxMsg {
print $_ . " here...\r\n";<<<<<<----------- here is 'SendMessage'
my @actions = split(/,/, $_);
print $actions[0] . " there...\r\n";
switch ($actions[0]) {
case 1 {defined(my $win = $Win32::GUI::Loft::window{Rx_Window})
or return(1);
$win->RxTextfield->Append("action 1\r\n");
chomp($actions[1]);
$win->RxTextfield->Append("$actions[1]\r\n");
open ACTION, "< $actions[1]" or die "cant open file : $!";
while (my $line = <ACTION> ) {
$win->RxTextfield->Append("$line\r\n");
}
}
case 2 {defined(my $win =
$Win32::GUI::Loft::window{Rx_Window}) or return(1);
$win->RxTextfield->Append("action 2\r\n");
}
case 3 {defined(my $win =
$Win32::GUI::Loft::window{Rx_Window}) or return(1);
$win->RxTextfield->Append("action 3\r\n");
chomp($actions[1]);
$win->RxTextfield->Append("$actions[1]\r\n");
open ACTION, "< $actions[1]" or die "cant open file : $!";
while (my $line = <ACTION> ) {
$win->RxTextfield->Append("$line\r\n");
}
}
else {defined(my $win = $Win32::GUI::Loft::window{Rx_Window})
or return(1);
$win->RxTextfield->Append("action unknown\r\n");
}
}
return(1);
}
Rx packet is a Win32:GUI application.
Rx packet passes the packet contents to a subroutine to process the
contents, except the contents once they get to the sub is always
'SendMessage'???
if I put the subroutine in the main part things are OK with using
$buf.
any help would be great
Routines......
Rx-------------------------------
my $readable_handles = new IO::Select();
$readable_handles->add($main_sock);
while (1) {
Win32::GUI:oEvents();
( my $new_readable) = IO::Select->select($readable_handles, undef,
undef, 0);
foreach my $sock (@$new_readable) {
if ($sock == $main_sock) {
my $new_sock = $sock->accept();
$readable_handles->add($new_sock);
} else {
# It is an ordinary client socket, ready for reading.
my $buf = <$sock>;
if ($buf) {
print "buf - $buf\n"; <<<<<<<<<--------here is correct contents
RxMsg($buf);
} else {
# Client closed socket. We do the same here, and remove
# it from the readable_handles list
$readable_handles->remove($sock);
close($sock);
}
}
}
}
}
sub RxMsg {
print $_ . " here...\r\n";<<<<<<----------- here is 'SendMessage'
my @actions = split(/,/, $_);
print $actions[0] . " there...\r\n";
switch ($actions[0]) {
case 1 {defined(my $win = $Win32::GUI::Loft::window{Rx_Window})
or return(1);
$win->RxTextfield->Append("action 1\r\n");
chomp($actions[1]);
$win->RxTextfield->Append("$actions[1]\r\n");
open ACTION, "< $actions[1]" or die "cant open file : $!";
while (my $line = <ACTION> ) {
$win->RxTextfield->Append("$line\r\n");
}
}
case 2 {defined(my $win =
$Win32::GUI::Loft::window{Rx_Window}) or return(1);
$win->RxTextfield->Append("action 2\r\n");
}
case 3 {defined(my $win =
$Win32::GUI::Loft::window{Rx_Window}) or return(1);
$win->RxTextfield->Append("action 3\r\n");
chomp($actions[1]);
$win->RxTextfield->Append("$actions[1]\r\n");
open ACTION, "< $actions[1]" or die "cant open file : $!";
while (my $line = <ACTION> ) {
$win->RxTextfield->Append("$line\r\n");
}
}
else {defined(my $win = $Win32::GUI::Loft::window{Rx_Window})
or return(1);
$win->RxTextfield->Append("action unknown\r\n");
}
}
return(1);
}