getsockopt (Bluetooth)

This function retrieves a socket option.

Note   This function is actually a Winsock function. However, the information that is presented in it is specific to Bluetooth.

int getsockopt(
  SOCKET s,
  int level,
  int optname,
  char FAR* optval,
  int FAR* optlen
);

Parameters

  • s
    [in] Descriptor identifying a socket. Must be a Bluetooth socket.
  • level
    [in] Level at which the option is defined. Must be SOL_RFCOMM.
  • optname
    [in] Socket option for which the value is to be retrieved. The following table shows possible values for this parameter.
    Value Description
    SO_BTH_GET_LINK Returns link key associated with peer Bluetooth device.

    optval must be a pointer to the initialized BTH_SOCKOPT_SECURITY structure;
    optlen must contain sizeof(BTH_SOCKOPT_SECURITY)

    SO_BTH_GET_MTU Returns MTU (maximum transmission unit). For connected socket, this is negotiated value, for server (accepting) socket it is MTU proposed for negotiation on connection request.

    optval is a pointer to int mtu;
    *optlen is sizeof(int)

    SO_BTH_GET_MTU_MAX Returns maximum MTU acceptable MTU value for a connection on this socket. Because negotiation has already happened, has little meaning for connected socket.

    optval is a pointer to int maxmtu;
    *optlen is sizeof(int)

    SO_BTH_GET_MTU_MIN Returns minimum MTU acceptable MTU value for a connection on this socket. Because negotiation has already happened, has little meaning for connected socket.

    optval is pointer to int minmtu
    *optlen is sizeof(int)

    SO_BTH_GET_XON_LIM Returns XON limit for a connection. XON limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification version 1.1). When amount of incoming data received, but not read by an application for a given connection grows past this limit, a flow control command is sent to the peer requiring suspension of transmission.

    optval is a pointer to int xon;
    *optlen is sizeof(int)

    SO_BTH_GET_XOFF_LIM Returns XOFF limit for a connection. XOFF limit is only used for peers that do not support credit-based flow control (mandatory in the Bluetooth Core Specification 1.1). If flow has been suspended because of buffer run-up, when amount of incoming data received, but not read by an application for a given connection falls below this limit, a flow control command is sent to the peer allowing continuation of transmission.

    optval is a pointer to int xoff;
    *optlen is sizeof(int)

    SO_BTH_GET_RECV_BUFFER Returns maximum amount of data that can be buffered for a connection. This buffer size is used to compute number of credits granted to peer device when credit-based flow control is implemented. This specifies the maximum amount of data that can be buffered.

    If credit-based flow is not implemented, it is possible to create buffer overruns, because, prior to the Bluetooth Core Specification 1.1, the flow control mechanism does not guarantee adherence to buffer limit (the peer might have already sent more data than can be held before receiving the flow off command. Setting relatively lower limits on XON will make this situation less probable.

    optval is a pointer to int buffer_size
    *optlen is sizeof(int)

    SO_BTH_GET_SEND_BUFFER Returns maximum amount of data that can be buffered inside RFCOMM (this is amount of data before call to send blocks).

    optval is a pointer to int buffer_size;
    *optlen is sizeof(int)

    SO_BTH_GET_V24_BR Retrieves last v24 and break signals set through MSC command from peer device.

    optval is a pointer to {int v42, int breaks};
    *optlen is 2 * sizeof(int)

    This call never blocks, even if no status update is received. It will always return the last (or default) values.

    SO_BTH_GET_RLS Retrieves last line status signals set through RLS command from peer device.

    optval is a pointer to int rls;
    *optlen is sizeof(int)

    This call never blocks, even if no status update is received. It will always return the last (or default) values.

    SO_BTH_GET_FLOW_TYPE Gets flow control type on the connected socket.

    optval is a pointer to unsigned int 1 or unsigned int 0, where: 1 = credit-based, 0 = legacy;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_PAGE_TO Gets the current page timeout. The socket does not have to be connected.

    optval is a pointer to unsigned int page timeout;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_SCAN Gets the current scan mode. The socket does not have to be connected.

    optval is a pointer to unsigned int scan mode;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_COD Gets the current class of the device. The socket does not have to be connected.

    optval is a pointer to unsigned int cod;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_LOCAL_VER Gets the local version of the baseband and L2CAP. The socket does not have to be connected.

    optval is a pointer to a BTH_LOCAL_VERSION structure;
    optlen is sizeof(BTH_LOCAL_VERSION)

    SO_BTH_GET_REMOTE_VER Gets the HCI version of the peer device.

    optval is a pointer to a BTH_REMOTE_VERSION structure;
    optlen is sizeof(BTH_REMOTE_VERSION)

    SO_BTH_GET_AUTHN_ENABLE Retrieves the authentication settings. The socket does not have to be connected.

    optval is a pointer to unsigned int authentication enable;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_LINK_POLICY Retrieves the link policy of the device.

    optval is a pointer to unsigned int link policy;
    optlen is sizeof(unsigned int)

    SO_BTH_GET_MODE Gets the current mode of the connection. The mode can either be sniff, park, or hold. The socket must be connected.

    optval is a pointer to int mode;
    optlen is sizeof(int)

  • optval
    [out] Pointer to the buffer in which the value for the requested option is to be returned.
  • optlen
    [in, out] Pointer to the size of the optval 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

For more information about the getsockopt function, see getsockopt (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 | BTH_SOCKOPT_SECURITY | BTH_LOCAL_VERSION | BTH_REMOTE_VERSION | Winsock Extensions | Bluetooth

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.