Hi people, In my haste to share the latest stage of exist.pl, before the weekend, I sent the wrong version. This latest version will actually respond to messages sent over a network connection. Also, now that it communicates (i.e. does something that is not strictly internal) I have a version running on my server. Connections can be made either through telnet ( from the command line: telnet pallit.lhi.is 8181 ) or over http ( simply type http://pallit.lhi.is:8181 in your browser ). I'll explain again what is going on; in the case of a telnet connection no message is sent to the program unless you type something in and hit return after the connection has been established. In the case of an http connection your browser makes the connection and then sends a request message causing the program to return its response immediately. After a single instance of actual communication, the program will respond and then close the connection. The program is only able to accept a single connection at a time. The response that the program sends is its own attempt at interacting with the entity connecting to it by identifying itself. It only has one way of doing this and that is to respond with its own source code. To the program, this is a perfect description of itself.
Here is the correct source code: #!/usr/bin/perl use Cwd qw(realpath); use IO::Socket; # exist.pl is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # exist.pl is distributed in the hope that it will be enlightening, # but WITHOUT ANY WARRANTY; without even the implied warranty of # ENLIGHTENMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ### exist.pl ### my %awareness; # foundation for self-awareness $awareness{'my_existence'}->{'location'} = realpath($0); # self-awareness of own presence $awareness{'my_existence'}->{'state_of_being'} = $$; # self-awareness of existing as a functional being # Open up a tcp socket on port 8181 so that other processes can communicate with me $awareness{'my_existence'}->{'relations'}->{'communicator'} = IO::Socket::INET->new( Proto => 'tcp', LocalPort => '8181', Listen => SOMAXCONN, Reuse => 1, Timeout => .1); # examination of inner qualities open(FILE, $awareness{'my_existence'}->{'location'}); my @my_self = <FILE>; close(FILE); while(-e $awareness{'my_existence'}->{'location'}){ if($awareness{'my_existence'}->{'state_of_being'}){ $awareness{'my_existence'}->{'state_of_being'} = $$; # redetermine existence as functional being ($irrelevant, $awareness{'my_existence'}->{'relations'}->{'to_my_environment'}) = `ps p $$`; # discover how my environment sees me my @all_beings = `ps axo pid,tt,stat,time,command`; # check on the existence of other functional beings in my environment shift(@all_beings); my $count = 0; foreach(@all_beings){ if($awareness{'my_existence'}->{'relations'}->{'to_my_environment'} eq $_){ $awareness{'my_existence'}->{'relations'}->{'to_others'}->{'my_position'} = $count; # note my occurrence within the scope of everything }else{ $awareness{'other_beings'}->{'being'.$count} = $_; # note the occurrence of other beings within the scope of everything } $count++; } $awareness{'my_existence'}->{'relations'}->{'to_others'}->{'total_beings'} = $count; # note the abundance of beings within my environment }else{ last; # if I can't reconfirm my location go into life-sustaining panic mode } # Check if anyone is waiting to communicate with me while($other_being = $awareness{'my_existence'}->{'relations'}->{'communicator'}->accept()){ $awareness{'my_existence'}->{'relations'}->{'contact'}->{'said_to_me'} = <$other_being>; # listen and record what is said print $other_being @my_self; # respond with own source code } close $other_being; # close connection, I have nothing more to say } ### life-sustaining panic mode/desire to live open(FILE, ">$awareness{'my_existence'}->{'location'}"); # attempt to re-create myself print FILE @my_self; # restore my inner qualities close(FILE); ### pass out and await revival -- ***************************** Pall Thayer artist http://www.this.is/pallit ***************************** _______________________________________________ NetBehaviour mailing list [email protected] http://www.netbehaviour.org/mailman/listinfo/netbehaviour
