From: Marcel Holtmann <marcel@holtmann.org>
To: "Collin R. Mulliner" <collin@betaversion.net>
Cc: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] RFCOMM support for nonblocking sockets
Date: Tue, 01 Jun 2004 19:25:52 +0200 [thread overview]
Message-ID: <1086110752.4578.6.camel@pegasus> (raw)
In-Reply-To: <20040601190522.78ecb2d9@coredump>
Hi Collin,
> I'm on 2.6.6-mh2 (should be the newest) ...
since today it is -mh3, but that doesn't matters ;)
> the code is:
>
> sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
>
> if (sock >= 0) {
> if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) {
> perror("fcntl()");
> }
> }
I don't know if this is the problem, but set the socket to non-blocking
after the bind() and the setsockopt() calls.
> psa.rc_family = AF_BLUETOOTH;
> psa.rc_channel = 0;
>
> // src == BDADDR_ANY
> if (bacmp(&src, BDADDR_ANY) != 0) {
> psa.rc_bdaddr = src;
> if (bind(sock, (struct sockaddr *)&psa, sizeof(psa)) < 0) {
> perror("Can't bind()");
> return(-1);
> }
> }
This check is not needed, because you can bind also src == BDADDR_ANY.
> psa.rc_channel = 1;
> psa.rc_bdaddr = dst;
Please try to use bacpy() to fill the rc_bdaddr.
> go:
> if (connect(sock, (struct sockaddr *)&psa, sizeof(psa)) != 0) {
> if(errno == EINPROGRESS) {
> // never reached!
> pf[0].fd = sock;
> pf[0].events = POLLOUT;
> poll(pf, 1, -1);
> goto go;
> }
> else {
> perror("Connect()");
> // allways prints "Resource temporarily unavailable"
> }
Run "hcidump -x" to see what is going on. Print out the errno.
Regards
Marcel
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
prev parent reply other threads:[~2004-06-01 17:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-01 16:32 [Bluez-devel] RFCOMM support for nonblocking sockets Collin R. Mulliner
2004-06-01 16:41 ` Marcel Holtmann
[not found] ` <20040601190522.78ecb2d9@coredump>
2004-06-01 17:25 ` Marcel Holtmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1086110752.4578.6.camel@pegasus \
--to=marcel@holtmann.org \
--cc=bluez-devel@lists.sourceforge.net \
--cc=collin@betaversion.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.