Anyone know what function or file in linux holds the algorithm that finds a random port to use for the bind() system call? I’m hunting all over and cannot find the method that contains this algorithm in the Linux source.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a long and complicated piece of code, which I’m not keen to try to grok. 🙂
Have a look at the
inet_csk_get_portfunction (innet/ipv4/inet_connection_sock.c) for TCP, andudp_lib_get_port(innet/ipv4/udp.c) for UDP. It’s valid, at least, for 2.6.31, though it may vary for different versions.