I am posting this as I've spent a few hours debugging this.
If you use socket_create / socket_bind with Unix domain sockets, then using socket_close at the end is not sufficient. You will get "address already in use" the second time you run your script. Call unlink on the file that is used for Unix domain sockets, preferably before you start to create the socket.
<?php
$socket_file = "./test.sock";
if (file_exists($socket_file))
unlink($socket_file);
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_bind($socket, $socket_file);
socket_close($socket);
unlink($socket_file);
?>