add -T option for TCP and use rpc.c functions