fix bug when using sockets