[ENet-discuss] Re: hello, is anyone out there?

Drew Ferraro gfilla at gmail.com
Wed Sep 29 16:22:11 PDT 2004


hey everybody. wow, that was fast. i thought for sure that this
mailing list was dead. im glad im wrong =). i had a question or 2, but
i *think* i've solved it.

first, im very new to this network programming thing, so bear with me
if you think im an idiot =). anyway, the question was that i noticed
enet had no conversion functions for converting signed values from /
to host / network byte order. however, i am now thinking that those
functions will work regardless if it is signed / unsigned, just as
long as it is 2 or 4 bytes. am i correct?

second, this is kind of less enet specific, but i guess ill ask. im
not sure how exactly to use convert my data to/from HBO/NBO. when
making a packet, i first create a char[] array. then i fill in the
data i need into this packet using either memcpy or just random
access. then i just use enet_packet_create() with this array to create
my packet. however, this doesnt account for endian differences. should
i, instead of putting the data directly into the char[], i should put
it into a temp variable, then convert this temp variable, and then add
this temp variable into the array? is this how it works basically? so,
i dont need the whole packet to be in order, just each pair of bytes
then, right? i want to make sure this is how it works...

also, i noticed that enet doesnt offer a signed data type. this is
kind of a problem for me. i've been trying to get my old pong clone
online, but i need a signed short int for this, because at times the
paddle could be a negative position (for example, for the brief
millisecond that the paddle goes out of bounds, immediately before
bounds checking is done to put the paddle in bounds).  anyway, i
realize i could just still use a signed short int, but the real
problem is consistency. i'd like to be consistant with my variable
usage. should i simply just typedef my own enet_sint8/16/32 variable
types?

last, for writing / reading to a buffer, i was thinking of using
SDL_net for this. they provide 4 functions : Read() and Write() 16/32
bit variables into a void *. this kind of goes with my last question
though - i was thinking, to be consistant, i could just use SDL data
types for all of this, which would also conveniently give me a Read()
and Write() function to a packet. however,  depending on the answers /
opinions on my previous questions, i would think typedef'ing my own 
enet_s variables and making my own Read() and Write() functions would
be both trivial and more consistant then throwing SDL into the mix.
but im using SDL anyway, so it wouldn't be a big deal.

thanks for any help!


More information about the ENet-discuss mailing list