Fix problem with sockets file descriptors

This error occurs because we use a pointer that is shared (??) between threads.

When the second thread starts, this thread changes the value of the sockfd(already sent to the first thread),
so we need to always deferencing this pointer, because this is safer.
clean-up the client a little