## Infinite loop while(1) { for($waitepid = 0; ($clientaddr = accept(SOCK_CLNT,SOCK_SRV) || $waitepid); $waitepid = 0, close(SOCK_CLNT)) { next if $waitepid and not $clientaddr; ## do things... } }