diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-05-08 17:18:18 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-05-08 17:18:18 +0000 |
commit | 0a2a889c91f9b671b7c31bcb6e4e53daf306fb7e (patch) | |
tree | f108e6a11200b22c6ccd2a3467f9579b23c5c594 | |
parent | a28f053fed22e73e57c701d146983e1fcd0dcac3 (diff) |
Add SDP_WAIT_ON_CLOSE flag for sdp_connect()
-rw-r--r-- | include/sdp.h | 1 | ||||
-rw-r--r-- | src/sdp.c | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/include/sdp.h b/include/sdp.h index 7f8ff538..640cac27 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -376,6 +376,7 @@ extern "C" { * Values of the flags parameter to sdp_connect */ #define SDP_RETRY_IF_BUSY 0x01 +#define SDP_WAIT_ON_CLOSE 0x02 /* * SDP Error codes @@ -3167,13 +3167,17 @@ sdp_session_t *sdp_connect(const bdaddr_t *src, const bdaddr_t *dst, uint32_t fl sa.l2_psm = 0; if (bacmp(src, BDADDR_ANY) != 0) { sa.l2_bdaddr = *src; - if (0 > bind(session->sock, (struct sockaddr *)&sa, sizeof(sa))) + if (bind(session->sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) goto fail; } + if (flags & SDP_WAIT_ON_CLOSE) { + struct linger l = { .l_onoff = 1, .l_linger = 1 }; + setsockopt(session->sock, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); + } sa.l2_psm = htobs(SDP_PSM); sa.l2_bdaddr = *dst; do - if (connect(session->sock, (struct sockaddr *)&sa, sizeof(sa)) == 0) + if (connect(session->sock, (struct sockaddr *) &sa, sizeof(sa)) == 0) return session; while (errno == EBUSY && (flags & SDP_RETRY_IF_BUSY)); } |