tcp src port

From: Antonio Mancuso (
Date: Tue Aug 12 2003 - 07:39:38 EST

I am not sure this question is right on this ML,
so if not please excuse me.

Is there a way (system call or other) to ask the OS
for a free TCP port in order to open a TCP connection with src port
the port returned from the previous system call?
So what I need to do is:

#1- ask the OS for a free TCP port
#2- bind a socket with this port as source port
#3- connect to the remote server with src port = port from #1

Thank you very much,
Antonio Mancuso
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at