2006-08-01 11:11:05

by Mayank BATRA

[permalink] [raw]
Subject: [Bluez-devel] Reading data on two l2cap sockets

Hi,

I am listening on two l2cap sockets (on different PSMs) and then connecting to these two sockets.
I am using select() to get data on these two sockets.

fd_set readfds;
FD_ZERO(&readfds);
FD_SET(sk1, &readfds);
FD_SET(sk2, &readfds);

while(1) {
int ready = select(FD_SETSIZE, &readfds, 0, 0, 0);
if(ready == 0)
continue;
if(ready == -1 && errno != EINTR)
break;
if(FD_ISSET(sk1, &readfds)) {
fprintf(stderr, "Got something on sk1\n");
/* some code */
}
if(FD_ISSET(sk2, &readfds)) {
fprintf(stderr, "Got something on sk2\n");
/* some code */
}
}

Now, if I send data on sk1, the line "Got something on sk1" is printed, but if I send data on sk2, the line "Got something on sk2" is never printed.
Is there any contraint that both the l2cap sockets should be on the same PSM?

Regards,
Mayank


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2006-08-01 11:56:14

by Mayank BATRA

[permalink] [raw]
Subject: Re: [Bluez-devel] Reading data on two l2cap sockets

Filippo,

> I don't know the internals but you should really FD_SET
> readfds after every
> select() invocation, i.e. move the readfds initialization
> inside the while loop.

Thanks for your suggestions. It actually works!
I had been spending so much time figuring out why it does not work.

Regards,
Mayank


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2006-08-01 11:32:28

by Filippo Giunchedi

[permalink] [raw]
Subject: Re: [Bluez-devel] Reading data on two l2cap sockets

On Tue, Aug 01, 2006 at 04:41:05PM +0530, Mayank BATRA wrote:
>
> Now, if I send data on sk1, the line "Got something on sk1" is printed, but if I send data on sk2, the line "Got something on sk2" is never printed.

I don't know the internals but you should really FD_SET readfds after every
select() invocation, i.e. move the readfds initialization inside the while loop.

filippo
--
Filippo Giunchedi - http://esaurito.net
PGP key: 0x6B79D401
random quote follows:

If there is any better use for being famous and respected than using
that status to question orthodoxy, I haven't found it yet.
-- Eric S. Raymond


Attachments:
(No filename) (0.00 B)
(No filename) (348.00 B)
(No filename) (164.00 B)
Download all attachments