Getting the source address of an incoming socket connection

后端 未结 3 2113
离开以前
离开以前 2020-12-15 19:01

I have a server with a incoming socket from a client. I need the get the IP address of the remote client. Tried searching google for in_addr but it\'s a bit tro

3条回答
  •  生来不讨喜
    2020-12-15 19:23

    Since you say it is an incoming connection from a client, as an alternative to getpeername you can just save the address that was returned by the accept() call, in the second and third parameters.

提交回复
热议问题