imcsk8 has asked for the wisdom of the Perl Monks concerning the following question:

monks, i'm having problems using a unix domain socket (i'm trying to connect to spamd using unix domain sockets). when i connect i don't get any errors, then write to the socket and still no errors, but when i shutdown the socket for writng and start reading, mi program just hangs.
i don't really know what am i doing wrong and i really appreciate your help.
the code i'm using is something like this:
#create the socket #i'm running spamd like this: #spamd -x -ufilter -d --socketpath=/var/spool/filter/spamd.sock my $DSOCKET = "/var/spool/filter/spamd.sock" my $socket = IO::Socket::UNIX->new(PeerAddr => $DSOCKET, Type => SOCK_DGRAM, Timeout => 0 ) || die "No puedo Conectarme a: $DSOCKET:$@\n"; #write to the socket my $msg = "PROCESS SPAMC/1.2\nContent-length: $ARGV[0]\nUser: filter\n +\r\n"; print $socket $msg; my $bytes=0; #while($line = <STDIN>){ while(<STDIN>){ $bytes += length($_); print "(BYTES=$bytes) ENTRANDO $_"; print $socket $_; } #finish writing: #i used shutdown i two ways with equal results #my $val = $socket->shutdown(1); my $val = shutdown($socket,1); print "FINISHED($val)\n"; #at this line it hangs. print "First Line ".<$socket>."\n";
thanks for your help


ignorance, the plague is everywhere
--guttermouth

Replies are listed 'Best First'.
Re: unix domain sockets problem
by tachyon (Chancellor) on Nov 04, 2004 at 01:34 UTC

    Perhaps there is no newline being sent so the response is being buffered? Try print while read($socket,$_,1); instead of the <$socket> I doubt $|++ at the top of the script will help but it won't do any harm to try it.

    cheers

    tachyon

      i tried print while read($socket,$_,1); but it still does not work, i'm kind of stuck here.
      is buffering the problem??


      ignorance, the plague is everywhere
      --guttermouth
Re: unix domain sockets problem
by dalgado (Initiate) on Nov 11, 2004 at 07:04 UTC
    Replace PeerAddr with Peer and try. HTH
Re: unix domain sockets problem
by b888 (Beadle) on Mar 30, 2006 at 14:32 UTC

    SOCK_STREAM instead of SOCK_DGRAM will surelly help.