this still produces a bad fd
work on refactor of server code