* [Bluez-devel] multiple connection problem
@ 2006-02-15 19:27 Irfan Ahmad
2006-02-15 19:31 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Irfan Ahmad @ 2006-02-15 19:27 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
Hi,
I am working on a software for bluetooth scatternet formation and routing.
When I try to accept two connections from different BT devices, the second
device gives a page fault error. Here I paste the code which I am trying to
use in my test run.
#include <stdio.h>#include <string.h>#include <sys/socket.h>#include
<bluetooth/bluetooth.h>#include <bluetooth/l2cap.h>
#define LQ 10int main(int argc, char **argv)
{
*struct* sockaddr_l2 loc_addr = { 0 }, rem_addr = { 0 };
char buf[1024] = { 0 },rem_name[100] = { 0 };
int s, client, bytes_read;
int opt = *sizeof*(rem_addr);
*// allocate socket*
s = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
*// bind socket to port 0x1001 of the first available *
*// bluetooth adapter*
loc_addr.l2_family = AF_BLUETOOTH;
loc_addr.l2_bdaddr = *BDADDR_ANY;
loc_addr.l2_psm = htobs(0x1001);
bind(s, (*struct* sockaddr *)&loc_addr, *sizeof*(loc_addr));
*// put socket into listening mode*
listen(s, LQ);
*while*(1)
{
*// accept one connection*
client = accept(s, (*struct* sockaddr *)&rem_addr, &opt);
ba2str( &rem_addr.l2_bdaddr, rem_name );
fprintf(stderr, "accepted connection from %s\n", rem_name);
*if* (fork()==0)
{
close(s);
memset(buf, 0, *sizeof*(buf));
*// read data from the client*
bytes_read = read(client, buf, *sizeof*(buf));
*if*( bytes_read > 0 ) {
fprintf(stderr,"%s: %s\n", rem_name,buf);
}
*// close connection*
close(client);
exit(0);
}
}
close(s);
}
Please help me regarding this problem. Also if some has worked on scatternet
projects or know about any, then please give me reference.
Thanks,
Irfan Ahmad
[-- Attachment #2: Type: text/html, Size: 3729 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* [Bluez-devel] multiple connection problem
@ 2006-02-16 13:49 Irfan Ahmad
2006-02-17 17:41 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Irfan Ahmad @ 2006-02-16 13:49 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
Dear Marcel,
Thank you for ur feed back and help. I had stated in my previous mail that
these dongles are working fine with other bluez functions/commands, but
gives an error when a unit becomes slave of multiple masters. So is it just
because of the hardware or it has some other reasons as well?
Secondly I had a question about piconets. As slaves in piconet cannot
directly communicate with each other and the master will act as a bridge for
their communication. Now is this bridging facility provided by bluez libs?
or do we have to implement it in our program (using Berkley Socket
Interface) meant for piconet communication?
Thanks
[-- Attachment #2: Type: text/html, Size: 920 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] multiple connection problem
2006-02-16 13:49 Irfan Ahmad
@ 2006-02-17 17:41 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2006-02-17 17:41 UTC (permalink / raw)
To: bluez-devel
Hi Irfan,
> Thank you for ur feed back and help. I had stated in my previous mail
> that these dongles are working fine with other bluez
> functions/commands, but gives an error when a unit becomes slave of
> multiple masters. So is it just because of the hardware or it has some
> other reasons as well?
it is basically a limitation of the hardware. BlueZ has no limitations
in these area.
> Secondly I had a question about piconets. As slaves in piconet cannot
> directly communicate with each other and the master will act as a
> bridge for their communication. Now is this bridging facility provided
> by bluez libs? or do we have to implement it in our program (using
> Berkley Socket Interface) meant for piconet communication?
No. You have to implement this by yourself.
Regards
Marcel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-02-17 17:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-15 19:27 [Bluez-devel] multiple connection problem Irfan Ahmad
2006-02-15 19:31 ` Marcel Holtmann
-- strict thread matches above, loose matches on Subject: below --
2006-02-16 13:49 Irfan Ahmad
2006-02-17 17:41 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).