targetddc
asked on
server/client pair using a unix socket
I need assistance with the following task and have included some code. the server receives only 1 client a writes a "." once a second to the socket for the client to read. The server should then close the connection, remove the socket and exit when given the TERM signal.
#!/usr/bin/perl -w
use Socket;
$socket_name = sockaddr_un("/tmp/mysock") ;
socket(SERVER, PF_UNIX, SOCK_STREAM, 0);
unlink "/tmp/mysock";
bind (SERVER, sockaddr_un("/tmp/mysock") )
or die "Can't create server: $!";
socket(CLIENT, PF_UNIX, SOCK_STREAM, 0);
unlink "/tmp/mysock";
connect (CLIENT, sockaddr_un("/tmp/mysock") )
or die "Can't connect to /tmp/mysock: $!";
#!/usr/bin/perl -w
use Socket;
$socket_name = sockaddr_un("/tmp/mysock")
socket(SERVER, PF_UNIX, SOCK_STREAM, 0);
unlink "/tmp/mysock";
bind (SERVER, sockaddr_un("/tmp/mysock")
or die "Can't create server: $!";
socket(CLIENT, PF_UNIX, SOCK_STREAM, 0);
unlink "/tmp/mysock";
connect (CLIENT, sockaddr_un("/tmp/mysock")
or die "Can't connect to /tmp/mysock: $!";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.