Forgot about the close(). Revised: #define CLOSESOCKET(sock) do { omni_mutex_lock sync(fds_lock); \ close(sock); \ FD_CLR(sock,&omniORB::fds); \ } while(0)