D
Didatus
i have a problem to send data over an unix domain socket
after the socket is created i am reading data from stdin und want to
send it over socket to a listener but i get an error. He can't write
into the socket.
This is my program:
#!/usr/bin/perl -w
use strict;
use IO::Handle;
use IO::Select;
use IO::Socket::UNIX;
use Getopt::Long;
Getopt::Long::Configure("bundling");
$|=1;
my $usock = "";
GetOptions ('socket|s=s' => \$usock);
my $sock;
$sock = IO::Socket::UNIX->new(PeerAddr => "$usock",
Type => SOCK_STREAM,
Timeout => 10 );
die "could not open socket: $!\n" unless $sock;
my $in = new IO::Handle;
$in->fdopen(fileno(STDIN),"r");
$in->blocking(0);
my $select = new IO::Select ($in);
while($select->can_read(200))
{
my $data = '';
while(my $length = $in->sysread($data,4096))
{
my $newlen = $sock->syswrite($data,$length);
}
}
after the socket is created i am reading data from stdin und want to
send it over socket to a listener but i get an error. He can't write
into the socket.
This is my program:
#!/usr/bin/perl -w
use strict;
use IO::Handle;
use IO::Select;
use IO::Socket::UNIX;
use Getopt::Long;
Getopt::Long::Configure("bundling");
$|=1;
my $usock = "";
GetOptions ('socket|s=s' => \$usock);
my $sock;
$sock = IO::Socket::UNIX->new(PeerAddr => "$usock",
Type => SOCK_STREAM,
Timeout => 10 );
die "could not open socket: $!\n" unless $sock;
my $in = new IO::Handle;
$in->fdopen(fileno(STDIN),"r");
$in->blocking(0);
my $select = new IO::Select ($in);
while($select->can_read(200))
{
my $data = '';
while(my $length = $in->sysread($data,4096))
{
my $newlen = $sock->syswrite($data,$length);
}
}