Networking ReadInt()

BlitzMax Forums/BlitzMax Programming/Networking ReadInt()

Goober(Posted 2010) [#1]
The documentation reads:

Method ReadInt()
Returns: The read value
Description: Read an int (four bytes) from the stream
Information: If a value could not be read (possibly due to end of file), a TStreamReadException is thrown.

____ If (SocketReadAvail(socket) >= 4) Then
________ intPacket = ReadInt(stream)
____ End If

Does this still apply if the application is run from a 64bit system? Should I be using SizeOf(int) ?

What if I have a C++ Winsock host running on a 64bit system, sending a 8bit integer? What will happen to my client on a 32bit system?



Some clarification would be awesome!
Thanks in advance.


plash(Posted 2010) [#2]
I'm not sure what C++ would use, but data types in Max are always the same, regardless of processor architecture.


Goober(Posted 2010) [#3]
ok, that clears a bunch up. Last thing to find out is if I should be checking the socketstream for 4 bytes or 8 bytes.


Dreamora(Posted 2010) [#4]
bm builds no 64bit as such there is no problem, it will always be 32bit


ziggy(Posted 2010) [#5]
BlitzMax ints are 32 bits, longs 64 and shorts 16. If you are not sure, you can always call len(variable) to know its size (on a non-class variable). --> This does not work. Use SizeOf instead.