# Quest, a computer role playing game system # Copyright (C) 2002 Willem Robert van Hage, details in the COPYING file. package com; use Socket qw(:DEFAULT :crlf); local($/) = $LF; my $END = "\027"; sub recv_string { my $handle = shift; my $input = ''; while (<$handle>) { s/$CR?$LF/\n/; last if /^$END$/; $input .= $_ } return $input } sub send_string { my ($peer,$str) = @_; print $peer $str, $CRLF, $END, $CRLF; } sub send_file { my ($peer,$file) = @_; open FILE, $file or return 0; while () { chomp; print $peer $_, $CRLF } close FILE; print $peer $CRLF, $END, $CRLF; return 1 } 1;