From: "Verber Seti" <verber_s@hotmail.com>
To: <bluez-users@lists.sourceforge.net>
Subject: [Bluez-users] sendto give invalid argument
Date: Fri, 13 Jan 2006 18:15:42 -0500 [thread overview]
Message-ID: <BAY103-W384F0CD67A81C73CE7167F7260@phx.gbl> (raw)
[-- 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 --]
next reply other threads:[~2006-01-13 23:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-13 23:15 Verber Seti [this message]
2006-01-13 23:32 ` [Bluez-users] sendto give invalid argument P. Durante
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=BAY103-W384F0CD67A81C73CE7167F7260@phx.gbl \
--to=verber_s@hotmail.com \
--cc=bluez-users@lists.sourceforge.net \
/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