From: Marcel Holtmann <marcel@holtmann.org>
To: "Abraham J. Velez (EndoraSoft)" <ajvelez@endorasoft.es>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: Question about the connect Function and BlueZ.
Date: Sat, 22 Aug 2009 12:59:24 -0700 [thread overview]
Message-ID: <1250971164.2950.20.camel@localhost.localdomain> (raw)
In-Reply-To: <508DFE744C1A4696B3D22CA7ED563C35@TSESUO>
Hi Abraham,
> Well, we have a problem in the Linux platfform with BlueZ. The problem is
> easy to explain:
>
> We open a connexion (with bluetooth) with connect function (we use socket).
> Every connexion make in his own thread. This connexions are with Obex Push
> profile. This works without problems.
>
> For the purposes of our applications, we need to cut this connection before
> the terminal (reduced the time of the ask in the terminal: the user confirm
> the sending). The call to connect function is blocking (because we need to
> know if the user of the terminal can not connect errno==ECONNREFUSED).
>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
> fcntl(func->handlesocket, F_SETFL, fcntl(func->handlesocket, F_GETFL,0) &
> ~O_NONBLOCK);
> func->refused = false;
> error = connect(func->handlesocket, (struct sockaddr *)&rem_addr,
> sizeof(rem_addr));
> if(error<0)
> {
> if(errno==ECONNREFUSED) func->refused = true;
> func->SetEvent(DIOLNXBTFSMEVENT_DISCONNECTING);
> break;
> }
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> The problem is: How cancel this block connexion make with connect function?
>
> If we call to this code (in other thread) the connect function waits to
> timeout of the terminal...
the problem seems similar or the same to what Nick posted a view weeks
ago. If you use blocking connect() in one thread the close() in another
thread will not terminate the connection attempt. As far as I can tell
this is true and should be fixed. It however works fine if you just
would use proper non-blocking connect() with a mainloop.
Regards
Marcel
prev parent reply other threads:[~2009-08-22 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-22 16:51 Question about the connect Function and BlueZ Abraham J. Velez (EndoraSoft)
2009-08-22 19:59 ` 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=1250971164.2950.20.camel@localhost.localdomain \
--to=marcel@holtmann.org \
--cc=ajvelez@endorasoft.es \
--cc=linux-bluetooth@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox