generic socket serving for Web
refactor a lot