Does Winsock2 have an API to define which TCP port a client uses to connect() to a server?
We need to connect() to a UNIX server, which only responds if the client TCP port is < 1024 (Reserved ports, which are accessible only to UNIX user "root", are in the range 1 to 1023. Non-reserved are in the range 1024 to 65535, read Port Usage).
If we use the plain Winsock2 API, we get a random TCP port number, and if it is above 1023, the server will not respond.
Simply
bind()the client socket to the desired local IP/port beforeconnect()'ing it to the server.