简体   繁体   中英

client port number

I was wondering how to, using C, find out what port a client is currently listening to. ie, I want to know what the source port is, not the destination port.

Thanks in advance!

Not sure what you mean. Clients don't listen, servers do.

If you're talking about how to scan for all open ports, then you might be after a port scanner. There are many many many many source codes available but I definitely don't recommend you use one of them, they are usually slow even if multithreading is enabled. Why? There's nmap : http://nmap.org/

The socket address structure should be filled-in by the connect() system-call. Check it after a successful return from that call.

根据您想要的内容(我现在很难猜测),您想要调用getsockname()或getpeername()。

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