I have found that this problem happens when I open a socket and close then open same socket (IP address and port) again quickly, it does not appear to happen if I put a delay between closing and opening port, maybe a semaphore/mutex problem?