#!/usr/bin/perl ################## #name: slut #by: jasper ################## use Class::Struct; use Time::localtime; use IO::Socket; use strict; ##################### #client configuration my $server = "localhost"; my $port = 7809; my $nick = shift || "slut"; struct( slut => [ server => '$', port => '$', nick => '$', usr_crypto => '%', #stores remote nick (key) and session encry +ption key (value) bytes_o => '$', bytes_i => '$', sock => '$' ]); print "+ - -\n* Slut v0.1a\n* By: Jasper\n+ - -\n\n"; my $sock = IO::Socket::INET->new (PeerAddr => $server, PeerPort => $port, Proto => "tcp", Reuse => 1)or die "Can't Connect to $s +erver!\n"; my $slut = slut->new(server => $server, port => $port, nick => $nick, sock => $sock); my $buff; print $sock "hey!"; while ($sock->recv($buff,256)) { chomp($buff); print "$buff\n"; $slut->bytes_i =+ length($buff); #$slut->bytes_o =+ length($data); }
#!/usr/bin/perl ################## # SlutServ v1.0 # by: jasper ################## use Class::Struct; use Time::localtime; use IO::Socket; use IO::select; use strict; use Constant DEBUG => 1; ##################### #server configuration my $name = "SlutServ"; #name of server my $port = shift || 7809; #listening port my $max_conn = 15; #maximum number of connections allowed struct( slut => [ name => '$', port => '$', users => '%', #stores remote nicks and their ip addresses usr_crypto => '%', #stores remote nick (key) and session encry +ption key (value) bytes_o => '$', bytes_i => '$', sock => '$' ]); print "+ - -\n* SlutServ v0.1a\n* By: Jasper\n+ - -\n\n"; my $listen = IO::Socket::INET->new ( LocalPort => $port, listen => $max_conn, Proto => "tcp", Reuse => 1) or die "Can't Start Server + on Port $port!\n"; print "Socket Initialized!\n" if DEBUG; my $slut = slut->new(name => $name, port => $port, sock => $listen); my $reader = IO::Select->new($listen) or die "Can't create i/o select +read object!"; print "Before while loop\n" if DEBUG; while (1) { print "Start While Loop\n" if DEBUG; if (my @ready = $reader->can_read(1)) { print "Just got @ready. moving to foreach loop\n"; foreach my $handle (@ready) { print "In socket foreach loop\n"; if($handle == $listen) { print "handle is \$listen\n" if DEBUG; my $connect = $listen->accept(); print "Accepted Connection!\n" if DEBUG; syswrite($connect,"200 SlutServ v0.1a"); } else { print "Isnt \$listen\n"; } } } else { print "Not Ready!\n"; } }
In reply to Client/Server by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |