C编程 - tcp套接字远程端口检索

doh*_*doh 2 c sockets network-programming

我有一个tcp连接套接字句柄,通过接受创建.只有手柄,而不是其他结构.如何从句柄中检索其REMOTE端口?我的意思是,连接Remote Client ---> Me的tcp源端口

Mar*_*som 7

getpeername函数获取有关远程端的信息,包括端口号; getsockname为连接的本地端做同样的事情.