Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Started with TCP sockets (see links), but really want Unix domain (##URL REMOVED##) (as the clients/server will be on the same machine).
The INET version works fine, but converting the socket to Unix as shown means no input seems to arrive at the server.
Server (##URL REMOVED##)
Client (##URL REMOVED##)use POSIX; use IO::Socket; use IO::Select; use Socket; use Fcntl; use Tie::RefHash; + $port = N; # change this at will + # Listen to port. #$server = IO::Socket::INET->new(LocalPort => $port, # Listen => 10 ) # or die "Can't make server socket: $@\n"; + unlink "/tmp/mysock"; $server = IO::Socket::UNIX->new(Local => "/tmp/mysock", Type => SOCK_STREAM, Listen => 5 ) or die "Failed to make socket: $!";
Obviously I've obscured the actual machine ip/port.use IO::Socket; + #$socket = IO::Socket::INET->new(PeerAddr => "x.x.x.x", # PeerPort => "N", # Proto => "tcp", # Type => SOCK_STREAM) # or die "Couldn't connect to x.x.x.x :N : $@\n"; + $socket = IO::Socket::UNIX->new(PeerAddr => "/tmp/mysock", Type => SOCK_STREAM, Timeout => 10 ) or die $@;
Edited by Chady -- removed link to copyrighted material
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unix domain sockets problem
by thospel (Hermit) on Oct 18, 2004 at 11:27 UTC | |
by Anonymous Monk on Oct 19, 2004 at 00:17 UTC | |
|
Re: Unix domain sockets problem (IP++)
by tye (Sage) on Oct 18, 2004 at 05:44 UTC |