getsockname (Bluetooth)
This function retrieves the local name for a socket.
Note This function is actually a Winsock function. However, the information that is presented in it is specific to Bluetooth.
int getsockname(
SOCKET s,
struct SOCK_ADDR* name,
int FAR* namelen
);
Parameters
- s
[in] Descriptor identifying a socket. - name
[out] Receives the address (name) of the socket. - namelen
[in, out] Size of the name buffer.
Return Values
If no error occurs, this function returns zero. If an error occurs, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
Remarks
Use getsockname to retrieve the server channel allocated to the socket by a call to bind and the Bluetooth address of local device.
The following example code shows how to use getsockname.
SOCKADDR_BTH sab;
int len = sizeof(sab);
if (0 == getsockname (s, &sab, &len)) {
wprintf (L"Local Bluetooth device is %04x%08x, server channel = %d\n",
GET_NAP(sab.btAddr), GET_SAP(sab.btAddr), sab.port);
}
For more information about the getsockname function, see getsockname (Windows Sockets) in the Winsock reference.
Requirements
OS Versions: Windows CE .NET 4.0 and later.
Header: Winsock2.h.
Link Library: Ws2.lib.
See Also
Bluetooth Functions | Winsock Extensions | Bluetooth
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.