With replicaset discovery this will not work as the hosts and ports will not match the replicaset configuration.
You will be able to connect to an individual node. Each member and client must be able to resolve and connect to the members as defined in the replicaset configuration.
The way I do it is:
Please note this is only applicable for testing/development as running 3 replicas on the same host is of no production benefit(ha,redendancy) you may as well run one mongod.