2004-06-16 13:17:58

by Williams, Richard

[permalink] [raw]
Subject: RE: [Bluez-devel] Problem with read on RFCOMM Sockets


I understand why strlen should not be used in this case, but why
unsigned char instead of char ? There are many examples of the=20
use of the generic file I/O read() function in the literature=20
using char buffers. Is this case different ?

thanks, Best regards,

Rich

Hi,

> Here is the source code. For testing the receiving of
> data I tried commenting the select loop, and do just
> receiveData, and I get the same results: read returns
> the correct number of bytes, but in the buffer is
> copied just one byte of data. Please tell me if I'm
> doing smth wrong. Thanks a lot.

your buffer should be "unsigned char" and you shouldn't use strlen() to
check to length of your buffer. Rely on the return value of read().

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2004-06-16 13:27:33

by Marcel Holtmann

[permalink] [raw]
Subject: RE: [Bluez-devel] Problem with read on RFCOMM Sockets

Hi Richard,

> I understand why strlen should not be used in this case, but why
> unsigned char instead of char ? There are many examples of the
> use of the generic file I/O read() function in the literature
> using char buffers. Is this case different ?

it actually depends on the other side. If the other side also uses char
then there should be no problem, but it is better to use unsigned char
if you don't know what the other side is sending.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel