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

Author Topic: UDP packet size  (Read 2629 times)

0 Members and 1 Guest are viewing this topic.

Reiv

  • Newbie
  • *
  • Posts: 13
    • View Profile
UDP packet size
« on: June 09, 2011, 02:53:02 pm »
I am using sfml for my project and i want to ask what is the difference in size between sending bitstream(char *data, sizeof(data) and sending packet with data?

Because sizeof(sf::Packet) returns 32 B to and that seems to much to me.
Does this mean that if i make my own bitstream representation of packet (char *mypacket = "00011100 ...etc" (eg first 4 bites represents size of head etc..)) and it will be smaller than 32bytes is it than smaller then packet or does Send function wraps some other data on it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
UDP packet size
« Reply #1 on: June 09, 2011, 08:49:03 pm »
sf::Packet only adds an extra Uint32 to the packet data (but this has nothing to do with the size of sf::Packet being 32, just a coincidence).

Using 4 bits instead of 32 would limit the size of a packet to 15 bytes... this is really small.
Laurent Gomila - SFML developer

Reiv

  • Newbie
  • *
  • Posts: 13
    • View Profile
UDP packet size
« Reply #2 on: June 09, 2011, 10:33:37 pm »
of course it was just example in reality it would be bigger, but since packet adds only 4 bytes i will stick with that, thanks for reply :)

Reiv

  • Newbie
  • *
  • Posts: 13
    • View Profile
UDP packet size
« Reply #3 on: June 16, 2011, 05:23:51 pm »
btw is there some way to send only bits? eg. for character direction in 2d game I would need only 4-bit information. (Dont look on portability right now)

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
UDP packet size
« Reply #4 on: June 16, 2011, 05:54:56 pm »
Quote from: "Reiv"
btw is there some way to send only bits? eg. for character direction in 2d game I would need only 4-bit information. (Dont look on portability right now)


No, smallest thing a computer can address is a byte, I am not experienced with network but I believe that is also the case for that field.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio