implement ROS_IP=localhost behavior for roscpp, and for outbound rospy connections

The wiki doc for ROS_IP:  http://wiki.ros.org/ROS/EnvironmentVariables    says that setting ROS_IP=localhost will "prevent remote components from being able to talk to your local component." This can be useful in some settings. However, this behavior was previously only implemented for inbound rospy topic connections and services. This pull request implements it for inbound and outbound roscpp connections, and for outbound rospy connections.
Since `ROS_IP` must contain a valid IP address when being set I think we should not check it for `localhost`.