Added socket semaphore for synchronize TCP and UDP socket