简体   繁体   中英

How to see if I connected to an ephemeral port?

I'm working on a port scanner that uses Linux connect system call and when I'm scanning localhost, sometimes I get false positives due to kernel allocating me the source port for the connection that is equal to the destination port. Is there a way to tell if the connection I established was made to an ephemeral port?

You can use getsockname to find out the local port the kernel assigned. Alternatively, you could use bind to pick the port yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM