Tcpport

@rcrichton fixes #252 and #265  please review