UNIX Domain Sockets

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);
}
}
 
N

nobull

[...] i get an error [...]

Saying "i get an error" without saying what that error is, is one of
those things you just should not do.

This newsgroup does not exist (see FAQ). Posting to newsgroups that
don't exist is also best avoided.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top