Getting binary data out of sockets
Peter Hatch
phatch at mojowire.com
Fri Mar 24 14:58:03 UTC 2000
Looks to me like you use #receiveDataInto: with a ByteArray argument. This
should simply store the received bytes into the ByteArray. Then, you can use
the #longAt:bigEndian: and #unsignedLongAt:bigEndian: methods on ByteArray to
read numeric data (by walking the ByteArray reading the longs from <index+4>).
If your data is Float data then you'll have to either implement
#floatAt:bigEndian: on ByteArray or you might be able to use a FloatArray
argument (maybe?). If not, you should be able to read the data into a
ByteArray and then send the array the message #asFloatArray.
HTH,
pete
> (I hope this gets through when the mail server wakes up)
>
> I assume the answer to this is pretty simple, but I don't see it. I'm
> opening a connection to a server I wrote (in C). The connection has to
> send a bunch of numeric data. I can put the data in an array and write it
> to the socket, but how do I read it as a binary on the client (Squeak)
> side?
>
> Thanks
> -Russ
>
More information about the Squeak-dev
mailing list
|