in reply to Writing a perl based 'Homework' Server.

Well, what you need is to learn Sockets with Perl. ;-P

If you want to enable the access of multi users in the same time to the server, take a look in this node: Re: spawning Perl scripts (Win32/Linux sample) (to run concorrent codes without threads). The use of fork is only recomended on Linux, on Win32 use threads (Perl-5.8.0).

But note that you need to know if who is connected to the server are sending right the data, or only opening the door, to avoid a basic DOS attack. To do that you can use IO::Select, but will read byte by byte!

Other thing is to limit the access to the srv for only some IPs:

my $server = IO::Socket::INET->new( Listen => 5, LocalAddr => '192.168.0.0', LocalPort => 5050, Proto => 'tcp' ) ;

About the users id and pass, you can (should) use a database. Just take a look in DBI. For a very simple database, with flat files, use DBD::CSV, or DBD::SQLite. The both don't need a main server, the module work as the srv.

And CPAN is your friend: http://search.cpan.org

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

Replies are listed 'Best First'.
Re: Re: Writing a perl based 'Homework' Server.
by DigitalKitty (Parson) on Apr 18, 2003 at 09:04 UTC
    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.
      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".