Since you can only call connect(2)
once for a stream-oriented socket, you really should use at least two sockets to create two simultaneous connections (or connection attempts).
You do not need to bind(2)
anything on client ports, except in strange cases. (I think of the Sunmapper RPC daemon, but luckily it has been almost ten years since I took care of the portmapper daemons. Also rlogin
needs to bind(2)
as a client using the host authentication method, which was horrible.)
source share