开发者

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!


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


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/


Depending on what you want (which I'm too obtuse to guess right now), you want to call either getsockname() or getpeername().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜