0

When I call accept to get a connecting socket, I can get the address of the connection. E.g.

sockaddr_in addr;
socklen_t addr_size = sizeof(addr);
const int sock = ::accept(main_socket, (sockaddr*)&addr, &addr_size);

// addr.sin_addr stores the address

char addr_str[256];
inet_ntop(addr.sin_family, &addr.sin_addr, addr_str, sizeof(addr_str));

But does the kernel retain the address associated with the socket? Say I don't save the addr struct and only save sock, is there a function I can call to get the address later?

SU3
  • 5,064
  • 3
  • 35
  • 66

0 Answers0