Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

IO::Socket::UNIX recvmsg error

by fuzzyping (Chaplain)
on May 16, 2005 at 01:36 UTC ( [id://457322]=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to create a IO::Socket::UNIX socket for receiving data from a netflow collector that can only write to files. I've created a small socket script (see below) that seems to run ok, but I get the following error when I run the collector:

... client_open_log: entering answer_open_log: entering answer_open_log: open: Operation not supported receive_fd: recvmsg: expected received 1 got 0#

And the script:

#!/usr/bin/perl use strict; use IO::Socket; use constant SOCK_PATH => '/tmp/flowpipe.sock'; $SIG{TERM} = $SIG{INT} = sub { exit 0 }; my $path = shift || SOCK_PATH; umask(0111); my $sock = IO::Socket::UNIX->new(Local => SOCK_PATH, Listen => SOMAXCO +NN); while (1) { my $data; my $peer = recv($sock, $data, 128, 0); print $data; } END { unlink $path if $path }

Any ideas what this error means or how to correct it?

Thanks,

Update: Corrected options passed to new().

Another Update: According to djm, flowd will not work with sockets at all. He's been able to provide patches to support FIFO properly, so this has been resolved.

-fp

Replies are listed 'Best First'.
Re: IO::Socket::UNIX recvmsg error
by Fletch (Bishop) on May 16, 2005 at 02:16 UTC

    I think you want a named pipe (see man mknod), not a UNIX domain socket. It still may have problems (for example, your writer may try and seek on the descriptor), but I think you're barking up the wrong tree with a UNIX domain socket.

      Yes, the writer does indeed try to seek on the descriptor. I gave up trying to use fifo/pipes for just this reason.

      -fp
        In this case, FIFOs would actually be more appropriate than sockets. Sockets are analogous to TCP or UDP connections (which is no coincidence), whereas FIFOs are closer to "ordinary" file operations. But since you've already been down that road, you'll have to look elsewhere.

        Have you considered processing lines from the file as they arrive, tail -f style?
Re: IO::Socket::UNIX recvmsg error
by thcsoft (Monk) on May 16, 2005 at 01:44 UTC
    i once had similar problems with AF_UNIX sockets, which is why i've been only using TCP sockets since.
    what happens, when you enable warnings?

    language is a virus from outer space.
      Unfortunately, netflow connectors generally only write to file. Their purpose is to read in a UDP netflow packet and log the data to disk. I'm trying to write a script which will read in from the collector's output and allow me to store to database.

      Warnings isn't giving me any additional information.

      -fp

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://457322]
Approved by kvale
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-09-10 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.