To bind by protocol identifier (PID), you must specify a protocol identifier in the data field of the CONN_DB parameter passed to bind. The datalen field contains the length of the protocol identifier. You can specify up to 102 bytes of protocol identifier, but only the first 16 bytes will be used for matching with user data in Incoming Call packets.
The user data field in an Incoming Call may be longer than the protocol identifier specified in bind. The match will be considered successful if the protocol identifier specified in bind is an initial sub-string of the user data in an Incoming Call. Thus, if you specify a zero-length protocol identifier in bind, it will match the user data in any Incoming Call.
You can enforce exact matching of the protocol identifier with user data in Incoming Call packets by setting the bit EXACT_MATCH (0x80) in datalen:
bind_addr.datalen |= EXACT_MATCH;
In this case, user data in an Incoming Call packet should match the protocol identifier specified in bind exactly (in content and length) in order for the match to be considered successful.
See Chapter 13, Sockets Programming Example," for references to sample code. A simple example is given below:
CONN_DB bind_addr; int s, error; /*We want to accept calls from any link, for the subaddress 01. * We must specify the two digit subaddress 01 and set the ANY_LINK * bit in the hostlen field. */ bind_addr.hostlen = 2 | ANY_LINK; /* there are 2 BCD digits */ bind_addr.host[0] = 0x01; /* We will specify a protocol identifier consisting of a single byte * with value 0x02. */ bind_addr.datalen = 1; bind_addr.data[0] = 0x02; error = bind(s, &bind_addr, sizeof(bind_addr));