ssouffri
ssouffri

Reputation: 5

howto get the destination address of accepted sockets?

I know you can get the destination address for messages coming into a SOCK_DGRAM socket by using recvmsg. I would like to know how to get the destination address (from peer perspective) for a socket created by calling the accept function on a socket of type SOCK_STREAM. In other words, how can I get the destination address of the SYN packet that caused accept to return?

Upvotes: 0

Views: 1313

Answers (2)

Perhaps with getpeername system call?

Upvotes: 2

Some programmer dude
Some programmer dude

Reputation: 409136

The function you look for is getpeername.

Upvotes: 1

Related Questions