implement TCP server and client