This is available as OS\getpeername in the www repository.
OS\getpeername
Get address of the connected peer
namespace HH\Lib\OS; function getpeername( FileDescriptor $fd, ): sockaddr;
See man 2 getpeername for details.
man 2 getpeername
FileDescriptor $fd
sockaddr