linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-users] Cannot send messages to my bluetooth enabled Phone using RFCOMM
@ 2005-12-06  5:02 Swathi Mathur80
  2005-12-07  9:07 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Swathi Mathur80 @ 2005-12-06  5:02 UTC (permalink / raw)
  To: bluez-users

Hello,
I am trying to send some data to my bluetooth enabled
Sony Ericsson
handphone T630 from my PC which has the bluez stack
running on it, i am using the RFCOMM.

I get the error message "Cant create socket" and "bad
file descriptor" 

Can someone help me in finding the mistake and in
correcting the below code

------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

int main(int argc, char **argv)
{
   struct sockaddr_rc addr = { 0 };
   int s, status;
   char dest[18] = "00:0A:D9:4C:EB:9A";  // BD of my
sony erricson phone
   
   //allocate a socket
   s =
socket(AF_BLUETOOTH,SOCK_SEQPACKET,BTPROTO_RFCOMM);

   if (s < 0) {
     printf("Cant create socket:\n");
   }


   //set the connection parameters(who to connect to)
   addr.rc_family = AF_BLUETOOTH;
   addr.rc_channel = (uint8_t) 1;
   str2ba(dest,&addr.rc_bdaddr);

  //connect to server
  status = connect(s, (struct sockaddr
*)&addr,sizeof(addr));

  //send a message
  if(status == 0)
  {
   status = write(s,"hello!",6);
  }

  if(status<0) perror("uh oh");
  close(s);
  return 0;

}

------------------------------------------------------------------------




		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



-------------------------------------------------------
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://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bluez-users] Cannot send messages to my bluetooth enabled Phone using RFCOMM
  2005-12-06  5:02 [Bluez-users] Cannot send messages to my bluetooth enabled Phone using RFCOMM Swathi Mathur80
@ 2005-12-07  9:07 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2005-12-07  9:07 UTC (permalink / raw)
  To: bluez-users

Hi Swathi,

> I am trying to send some data to my bluetooth enabled
> Sony Ericsson
> handphone T630 from my PC which has the bluez stack
> running on it, i am using the RFCOMM.
> 
> I get the error message "Cant create socket" and "bad
> file descriptor" 
> 
> Can someone help me in finding the mistake and in
> correcting the below code
> 
> ------------------------------------------------------------------
> #include <stdio.h>
> #include <string.h>
> #include <sys/socket.h>
> #include <bluetooth/bluetooth.h>
> #include <bluetooth/rfcomm.h>
> 
> int main(int argc, char **argv)
> {
>    struct sockaddr_rc addr = { 0 };
>    int s, status;
>    char dest[18] = "00:0A:D9:4C:EB:9A";  // BD of my
> sony erricson phone
>    
>    //allocate a socket
>    s =
> socket(AF_BLUETOOTH,SOCK_SEQPACKET,BTPROTO_RFCOMM);
> 
>    if (s < 0) {
>      printf("Cant create socket:\n");
>    }

the RFCOMM protocol is a SOCK_STREAM.

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://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-12-07  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06  5:02 [Bluez-users] Cannot send messages to my bluetooth enabled Phone using RFCOMM Swathi Mathur80
2005-12-07  9:07 ` 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).