Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: No endianess problems for double/float?  (Read 2422 times)

0 Members and 1 Guest are viewing this topic.

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
No endianess problems for double/float?
« on: June 12, 2011, 05:56:27 pm »
Hi,

I recognized, that in SFML 1.6 the sf::packet code for float and double don't do anything about endianess.

Is there no endianess problem for float/double?

I used google and found some articles about how to convert endianess of float/double, so it seems if these datatypes also have endianess, but I'm not sure...

Another question:
With which header do you get access to functions like htonl?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No endianess problems for double/float?
« Reply #1 on: June 12, 2011, 06:04:48 pm »
Quote
Is there no endianess problem for float/double?

To be honest, this point is very confusing. Apparently the IEEE-754 standard doesn't say anything about endianess, but in practice it appears to be always the same across platforms.

Quote
With which header do you get access to functions like htonl?

On which OS? ;)
Laurent Gomila - SFML developer

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
No endianess problems for double/float?
« Reply #2 on: June 12, 2011, 06:17:38 pm »
I was hoping for an platform independant header :-)

Do I have these functions automaticully when including SFML/Network.hpp?

Maybe you wonder, why I'm asking all this.
The non-blocking mode of sf::SocketUDP with sf::Packet seems not to work very good for me.
After receiving a packet over udp with return value sf::Socket::DONE the packet is not valid after reading out the same amount of values I put in on the server side.
Maybe it's just wrong usage by me...

I thought about giving boost::asio a try, but afaik it's lacking features for binary data, so I think about try to roll my own on top of boost::asio.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
No endianess problems for double/float?
« Reply #3 on: June 12, 2011, 07:27:41 pm »
Quote
I was hoping for an platform independant header

You can't expect anything standard if you want to use the lowest possible level functions.

Quote
Do I have these functions automaticully when including SFML/Network.hpp?

No, they are hidden in the implementation so that users are not polluted with OS-specific headers.

Quote
The non-blocking mode of sf::SocketUDP with sf::Packet seems not to work very good for me.

UDP and packets don't mix well together in SFML 1.6. In SFML 2 they now work perfectly (I've improved this particular code yesterday).
Laurent Gomila - SFML developer

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
No endianess problems for double/float?
« Reply #4 on: June 12, 2011, 07:39:36 pm »
Thx for your help!
I will definitely give SFML 2.0 a try!

The only thing which does not really convince me so far is the support for asynchronous io.
The biggest problem is that I can't poll if the socket is busy without actually trying to send or receive.
Maybe i will use an additional thread which does synchronous I/O to emulate async I/O.

Edit:
For the additional thread I would need something like a wait condition I think...
Edit2:
I now tried sfml 2.0 and it doesen't help.
Maybe its up to my usage, but I don't know what I'm doing wrong...

 

anything