[Gambas-user] gb3 RC1: using structures to replace the loss of Mk$ functions

Kevin Fishburne kevinfishburne at ...1887...
Sun Apr 3 22:07:34 CEST 2011


On 04/03/2011 02:27 PM, Benoît Minisini wrote:
>
> OK... I should have read all that more carefully, as I have said rubbish.
>
> Sending a message to an UDP socket can only be done with a string or a
> structure. If you use several WRITE instructions, you will get one message by
> WRITE. Not a good thing...
>
> So my answer about object-oriented programming is useless. Or at least it will
> help you to understand what object-oriented programming is.

I appreciate the explanation. It's definitely something I need to learn 
more about if I want to grow as a programmer.

> So now ? I think I have to think... The problem with Mk*() functions is their
> endianness dependency. Maybe I can make these functions endianness-aware, but
> it is not a immediate job.

For endianness to matter the client and server programs would have to 
have different endiannesses and the program receiving the UDP string 
would have to be converting the string back into variables using 
functions like Single@ or equivalents. If the sender was big-endian and 
the receiver was little-endian then the bit order would be backward on 
the receiving end and thus an unexpected value.

The problem is that Mk*() and *@() are simple functions that don't 
directly have anything to do with networking or UDP packets. That is 
just the only use anyone's thought of so far. Because of that I don't 
see how these functions could possibly be made endianness-aware in that 
context.

If endianness is an issue with a particular program, the solution would 
be for the programmer to add endianness data manually to the UDP packet 
so the receiver would know how to convert it. The same thing would 
probably have to be done if a program wrote a bunch of variables to a 
data file, then sent the data file to a program with a different 
endianness that needed to read it back into variables. To assist this 
solution all the Mk*() and *@() functions could have an optional 
parameter to specify endianness, defaulting to the host architecture's 
endianness if not otherwise specified.

For now I may actually use file I/O to convert the values back and 
forth, though I'll be looking at memcpy too.

> Kevin, another Gambas 3 RC1 release killer. ;-)

Haha, sorry.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list