rojmab:
A few miscellaneous notes:
- Line 42 ($client="";) is unnecessary, as the very next line reassigns $client with the result of $sock->accept().
- You're not checking whether $sock->accept() fails, which is the symptom you're reporting, I believe.
- You should remove the inner while loop (starting at line 48), as you go to great lengths in never executing it again (the myriad last statements). Just delete lines 48, 49, 66, 71, 77, 80 and 81, and then fix the indentation.
...roboticus