socket ile bi ilişkisi yok bu olayın. ordaki döngü sorgu sonucu dolu geldikçe tekrar etmez.
if(mysql_num_rows($sql)) break; bu cumleden dolayı..

ama boş gelen bir sorgu için de sonsuz döner sonuc da stack overflow..