Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Client for custom file server

by Aighearach
on Apr 27, 2000 at 00:02 UTC ( #9314=sourcecode: print w/replies, xml ) Need Help??
Category: Network
Author/Contact Info Paris Sinclair
Description: This is the client program for my custom file server, written for inclusion in bots on the Free Internet Chess Server.
#!/usr/bin/perl -w
use IO::Socket;
use strict;

unless (@ARGV >= 3) { die "usage: $0 server port file(s)\n"; }
my ($server, $port, @file_list) = @ARGV;
my ($buffersize, $buffer, $data, $file, $connection) = (1024);

if ($file_list[0] eq '*') {
    @file_list = get_file_list('.');
foreach $file (@file_list) {
    my $size = (stat($file))[7];
    my  $retry_count = 0;
    open(FILE, $file);
    binmode FILE; 
    until ($connection = IO::Socket::INET->new(Proto => "tcp",
                           PeerAddr => $server,
                           PeerPort => $port) || (++$retry_count) > 30
+) { 
    print STDERR "[Connected to $server:$port]\n";
    print $connection "[FILENAME: \"_$file\"]\012";
    print $connection "[SIZE: \"$size\"]\012";
    while (read(FILE, $data, $buffersize)) {
    print $connection $data;

sub get_file_list {
    my ($dir) = @_;
    my ($file, @file_list);
    opendir(DIR,$dir) || die "cannot open directory: $!";
    while (defined( $file = readdir(DIR) )) {
    push(@file_list, $file);
    return @file_list;
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://9314]
[marto]: yeah, the whole infrastructure has changed, and video codecs have moved on a great deal
[Corion]: marto: Redoing something on new infrastructure sounds fun. At least you can reuse your previous experience :)
[marto]: I'm looking forwads to it. The video sources are dying, and they don't have the hardware to play them back (old tape formats, not just VHS + Laserdisc etc)
[marto]: I'll be interested to see what difference in terms of file size/quality the new codecs make. I enjoy working on things like this, so that's a bonus
[Corion]: Ah, cool! So it's not an inhouse youtube but for a wider consumption
[marto]: last time it was IE6 clients, now they're on 11, so more scope there also, in terms of UI and playback

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2017-07-28 09:17 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (425 votes). Check out past polls.