Fixing the socket undefined error