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
In reply to Unix domain sockets problem by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |