Add TCP thread server and use sockets api instead