Linux bluetooth development
 help / color / mirror / Atom feed
From: Max Krasnyansky <maxk@qualcomm.com>
To: Stephen Crane <steve.crane@rococosoft.com>,
	bluez-devel@lists.sourceforge.net
Cc: marcel@rvs.uni-bielefeld.de
Subject: Re: [Bluez-devel] EBADFD on RFComm connect
Date: Tue, 22 Jul 2003 17:33:15 -0700	[thread overview]
Message-ID: <5.1.0.14.2.20030722172712.098034f8@unixmail.qualcomm.com> (raw)
In-Reply-To: <1058880571.1670.425.camel@baroque.rococosoft.com>

At 06:29 AM 7/22/2003, Stephen Crane wrote:
>Hi Max, Marcel,
>Under what circumstances can connect() return EBADFD?
>
>I have a couple of programs (attached) one of which opens a listening
>socket and accepts 32 connections. The other loops attempting 32
>connections to the same channel. On the second connection connect()
>always fails with EBADFD. (If I leave in the 0.5 second delay it all
>works fine.)

You can not do this
        while (0 > connect(s, (struct sockaddr *)&addr, sizeof(addr)))
               if (errno != EBUSY) {
                   perror("connect");
                   return -1;
               }

If connect returns EBUSY error you have to close() the socket. And it does
indeed return EBUSY in your case (I ran the progs) because close() is asynchronous
and that channel still exist (two connections on the same channel are not allowed 
in RFCOMM). What you can do to avoid that error is to enable SO_LINGER option on that
socket, in which case close() will be synchronous. 

Max
 

  reply	other threads:[~2003-07-23  0:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-22 13:29 EBADFD on RFComm connect Stephen Crane
2003-07-23  0:33 ` Max Krasnyansky [this message]
2003-07-24 14:09   ` [Bluez-devel] " Stephen Crane
2003-07-24 17:38     ` Max Krasnyansky

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=5.1.0.14.2.20030722172712.098034f8@unixmail.qualcomm.com \
    --to=maxk@qualcomm.com \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=marcel@rvs.uni-bielefeld.de \
    --cc=steve.crane@rococosoft.com \
    /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