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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.