[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using listen to receive commands
From: |
Paul Kienzle |
Subject: |
Re: using listen to receive commands |
Date: |
Mon, 20 Mar 2006 19:34:05 -0500 |
On Mar 20, 2006, at 12:55 PM, Corbin Champion wrote:
Are you familiar with perl? I am not familiar with tcl, but I have
taken a look at both files you pointed me at, and they seem to make
sense to help get me started. Based on looking at the eval function
and then converting to perl, I am trying to do a basic test of talking
to octave from perl. I have included the code here. The perl script
is able to connect to the octave that is listening "listen(2000)". It
then prints the !!!x format, is this done correctly?...probably not.
Then I see after the disconnect from the socket "accept: no child
processes" printed out on the octave terminal that is listening. I
know something is wrong only by the fact that the file temp.txt was
not created. What should I expect to have printed out on the octave
terminal as connections are made and commands are sent?
Assuming sprintf('%b',60) produces a 4 byte integer, then what you have
looks correct. Is the integer in network byte order (big endian)? Or
is it an Intel little endian format?
Also, you should probably add fclose(fid); to your command. I don't
know what the behaviour on cygwin when terminating a process without
closing the associated files.
The "accept: no child processes" is a problem on some versions of
Windows that I don't understand. If you listen(2000,"nofork") then the
problem goes away (but you can only have one child listening at a
time). Note that this requires a newer version of listen.oct than that
available on the octave2.1.50a. I have a newer version available at
http://www.ncnr.nist.gov/reflpak/listen.oct
for the 2.1.50a version. The new windows package and the cygwin
package already support "nofork".
- Paul
#!/usr/bin/perl -w
# send.pl
# a simple client using IO:Socket
#----------------
use strict;
use IO::Socket;
my $host = shift || 'localhost';
my $port = shift || 2000;
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port,
Proto => 'tcp');
$sock or die "no socket :$!";
print scalar(localtime);
print $sock "!!!x";
print $sock sprintf("%b",60);
print $sock "fid = fopen('temp.txt', 'w'); fprintf(fid,'this is
perl\n');";
print scalar(localtime);
sleep(5);
close $sock;
Thanks for you help!
Corbin
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- using listen to receive commands, Corbin Champion, 2006/03/17
- Re: using listen to receive commands, Paul Kienzle, 2006/03/17
- Re: using listen to receive commands, Corbin Champion, 2006/03/20
- Re: using listen to receive commands,
Paul Kienzle <=
- Re: using listen to receive commands, Corbin Champion, 2006/03/20
- Re: using listen to receive commands, Paul Kienzle, 2006/03/20
- Also learning about Listen, Doug Stewart, 2006/03/20
- Re: Also learning about Listen, Paul Kienzle, 2006/03/20
- Re: Also learning about Listen, Doug Stewart, 2006/03/20
- Re: Also learning about Listen, Doug Stewart, 2006/03/21
- Re: using listen to receive commands, Corbin Champion, 2006/03/20