IO::Socket::UNIX questions

From: Dave Kettmann (dkettmann_at_netlogic.net)
Date: 12/30/04


Date: Thu, 30 Dec 2004 16:23:23 -0600
To: "Perl List (E-mail)" <beginners@perl.org>

Hello list,

I am working with UNIX Sockets and have some questions that I cant seem to find answers to on the web.

1: Are UNIX sockets bi-directional?

2: If so, what is the proper way to 'setup' the connection? (will post what I have below)

3: Do UNIX sockets have less overhead than INET sockets?

Here is what I have for the OO connections:

Server:

my $server = IO::Socket::UNIX->new(Local => "/tmp/mysock",
                                   Type => SOCK_DGRAM,
                                   Listen => 5 )
  or die $@;

Client:

my $client = IO::Socket::UNIX->new (
                                   Type => SOCK_DGRAM,
                                   Peer => "/tmp/mysock",
                                   )
or die $@;

Right now, I am able to send information from the client to the server, but not the other way around. When I try this, I get:send:

Cannot determine peer address at server.pl line 21

Here are lines 17-22:

  if($text ne 'exit')
  {
    print "\nReceived message '", $text,"'\n";
    my $send = "I got: $text\n";
    $server->send($send,128); # <------- Line 21
  }

I have tried multiple things with the creation of the socket, but cant get the right combination. I am beginning to think that UNIX sockets are not bi-directional, but I hope someone proves me wrong.

If more information is needed, let me know.

Thanks for the help,

Dave Kettmann
NetLogic
636-561-0680



Relevant Pages

  • RE: :Socket::UNIX questions
    ... > I am working with UNIX Sockets and have some questions that I ... > cant seem to find answers to on the web. ... I am able to send information from the client to ... sub start_daemon { ...
    (perl.beginners)
  • Re: IO::Socket::UNIX questions
    ... Do UNIX sockets have less overhead than INET sockets? ... > or die $@; ... I am able to send information from the client to the ... > cant get the right combination. ...
    (perl.beginners)
  • Re: UDP recvfrom unable to get senders address
    ... I have a udp local client server program and I am trying to print the ... By definition of UNIX sockets the other peer is always localhost. ... it makes no sense for a Unix socket client to bindat his end. ...
    (comp.unix.programmer)
  • Re: How to check UID of process on the other side of local TCP/UDP connection
    ... does doing a netstat and matching the client port with a pid work for you? ... Client communicates with server via TCP or UDP. ... Unix sockets (unless of course Unix sockets are the only good way to ...
    (Focus-Linux)