私はL2CAPソケットを作成し、デバイスに接続し、同じものにmtuを設定する必要があるコードを持っています。そうしようとすると「無効な引数」というエラーが表示されます。ソケットが作成され、バインドが1つのbd_addressに対して行われ、connectも実行されます。setsocketoptions L2CAP_OPTIONSが "無効な引数エラー"で失敗する
sk = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP);
if (sk < 0)
{
perror("Can't create socket");
}
/* Bind to local address */
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
str2ba(LOCAL_DEVICE_ADDRESS, &addr.l2_bdaddr);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{
perror("Can't bind socket");
}
/* Connect to remote device */
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
str2ba(REMOTE_DEVICE_ADDRESS, &addr.l2_bdaddr);
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{
perror("Can't connect");
}
perror("connected");
if (getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)) < 0)
{
perror("Can't get L2CAP MTU options");
close(sk);
}
opts.imtu = 672; //this is default value
opts.omtu = 672; //tried changing this too
if (setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)) < 0)
{
perror("Can't set L2CAP MTU options");
close(sk);
}
「L2CAP MTUオプションを設定できません:無効な引数」 – dfordevy