in reply to IO:Socket question... sort of :)
Not really a direct answer, but consider using POE (wiki).