in reply to Re: Writing a perl based 'Homework' Server.
in thread Writing a perl based 'Homework' Server.

Hi.

Thanks for the advice. I am 'limited' to perl 5.6 ( school ) but I did manage to expand on my code base:

# Perl server #!/usr/bin/perl -w use strict; use IO::Socket::INET; local $| = 1; my $ID; my $PW; my $port = 8500; my $client; my $server = new IO::Socket::INET( LocalPort => $port, Type => SOCK_STREAM, Listen => 5, Proto => 'tcp', Reuse => 1, ) or die "Couldn't construct server on port: $port : $!\n"; $client = $server->accept(); print $client "ID:"; $ID = <$client>; print "I received $ID\n";


#Perl client. #!/usr/bin/perl -w use strict; use IO::Socket::INET; local $| = 1; my $host = '127.0.0.1'; my $port = 8500; my $ID; my $PW; my $client = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp', Type => SOCK_STREAM, ) or die "Couldn't create client : $!\n"; my $data = <$client>; print $data; chomp( $ID = <$client> ); print $client $ID;


The primary problem is I can pass the prompt to the client ( e.g. ID? ), but I don't know how to obtain the input then return that to the server. I tried <STDIN> but the program simply hung. If I can prompt for three scalars ( ID, PW, and assignment_to_submit ) and return each piece of input to the server, I don't forsee too much difficulty in completing the remainder of the project.

Thanks,
-Katie.

Replies are listed 'Best First'.
Re: Re: Re: Writing a perl based 'Homework' Server.
by gmpassos (Priest) on Apr 19, 2003 at 17:03 UTC
    Well, STDIN should work!
    print "Type some: " ; my $in = <STDIN> ; chop($in) ; print "In: $in\n" ;
    But in what OS the client work? You can put a GUI for the app, like wxPerl or TK.

    Graciliano M. P.
    "The creativity is the expression of the liberty".