The client shouldn't be calling accept, should it?
The server should, in order to accept new clients.
Here's a really simplistic example of sending
a file across a socket. Here's the server:
use IO::Socket;
my $server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => 'localhost',
LocalPort => 5050,
Proto => 'tcp'
) or die "Can't create server socket: $!";
my $client = $server->accept;
open FILE, ">out" or die "Can't open: $!";
while (<$client>) {
print FILE $_;
}
close FILE;
And here's the client:
use IO::Socket;
my $server = IO::Socket::INET->new(
PeerAddr => 'localhost',
PeerPort => 5050,
Proto => 'tcp'
) or die "Can't create client socket: $!";
open FILE, "in";
while (<FILE>) {
print $server $_;
}
close FILE;
This should get you started. Just start up the
server in the background, then run the client,
and it should send the contents of "in" to "out",
over the socket.
You'll probably want to tinker around with it
a bit--perhaps put in some command line options
for the host and port; make it so that the server
handles multiple connections (using IO::Select);
etc.