[#Sock-GetSockName]
= xref:Sock.adoc[Sock]::GetSockName
:relfileprefix: ../
:mrdocs:

getsockname(2) wrapper&period; Equivalent to `getsockname(m&lowbar;socket, name, name&lowbar;len)`&period; Code that uses this wrapper can be unit tested if this method is overridden by a mock Sock implementation&period;

== Synopsis

Declared in `&lt;util&sol;sock&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
virtual
int
GetSockName(
    sockaddr* name,
    socklen&lowbar;t* name&lowbar;len) const;
----

== Return Value

0 on success, or &hyphen;1 on error (with errno set)&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *name*
| Buffer that receives the local address of the socket&period;
| *name&lowbar;len*
| On input the size of `name`, on output the actual address size&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
