mod: refactory some code
add: remote tcp connection support