Get remote address/IP - C Berkeley Sockets
Asked Answered
C

2

5

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.

Colour answered 22/1, 2011 at 19:42 Comment(0)
G
8

getpeername

Garbo answered 22/1, 2011 at 19:47 Comment(0)
S
0

See the getpeername() system call.

Staal answered 17/5, 2011 at 10:22 Comment(1)
Please add more details.Belleslettres

© 2022 - 2024 — McMap. All rights reserved.