Get remote address/IP - C Berkeley Sockets

ε祈祈猫儿з 提交于 2020-01-14 10:49:07

问题


If I have a socket file descriptor connected (either by connect or by bind), type SOCK_STREAM, is it possible to get the remote address / IP address?

I need to do this within a function where I don't have any other data than the socket file descriptor.


回答1:


getpeername




回答2:


See the getsockname() system call.



来源:https://stackoverflow.com/questions/4770127/get-remote-address-ip-c-berkeley-sockets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!