* [Bluez-users] sendto give invalid argument
@ 2006-01-13 23:15 Verber Seti
2006-01-13 23:32 ` P. Durante
0 siblings, 1 reply; 2+ messages in thread
From: Verber Seti @ 2006-01-13 23:15 UTC (permalink / raw)
To: bluez-users
[-- Attachment #1: Type: text/plain, Size: 1985 bytes --]
Hello, I'm new to using Bluez. I need to create a simple program to send text over a specific type of port (SOCK_DGRAM, BTPROTO_L2CAP). The code compiles fine, but when I run it i get the following error (from then sendto function). Send Failed: Invalid argument What might the problem be? My code is shown below. Thank-you so much for any help that you can offer.,verber #include <stdio.h>#include <stdlib.h>#include <errno.h>#include <string.h> #include <bluetooth/bluetooth.h>#include <bluetooth/l2cap.h>#include <bluetooth/hci.h>#include <bluetooth/hci_lib.h> #include "l2cap_msg_send.h" int fd; int send_msg(){ /* SETTING UP SOCKET */ struct sockaddr_l2 addr; unsigned int psm = 0x1001; fd = socket(AF_BLUETOOTH, SOCK_DGRAM, BTPROTO_L2CAP); if (fd == -1) { fprintf(stderr, "Could not open socket: %s\n", strerror(errno)); exit(1); } addr.l2_family = AF_BLUETOOTH; bacpy(&addr.l2_bdaddr, BDADDR_ANY); addr.l2_psm = htobs(psm); if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { fprintf(stderr, "Could not bind socket: %s\n", strerror(errno)); exit(1); } /* END: SETTING UP SOCKET*/ /* SET UP MSG */ char recv_addr[18] = "00:0A:3A:53:1C:42"; struct sockaddr_l2 recipient; recipient.l2_family = AF_BLUETOOTH; str2ba(recv_addr,&(recipient.l2_bdaddr)); recipient.l2_psm = htobs(psm); char message[] = "57 123 189"; /* END: SET UP MSG */ /* SEND MSG */ int ret; socklen_t len; len=sizeof(recipient.l2_bdaddr); size_t msg_len; msg_len=sizeof(message); ret = sendto(fd, &message, msg_len,0, (struct sockaddr *) &recipient, len); printf("%d\n",ret); if( ret < 0 ) fprintf(stderr,"Send Failed: %s\n",strerror(errno)); /* END: SEND MSG */ // close(fd); return 0;}
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
[-- Attachment #2: Type: text/html, Size: 2732 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-13 23:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-13 23:15 [Bluez-users] sendto give invalid argument Verber Seti
2006-01-13 23:32 ` P. Durante
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox