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

Author Topic: Packet with fixed size  (Read 2148 times)

0 Members and 1 Guest are viewing this topic.

Hamed

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Packet with fixed size
« on: February 20, 2013, 12:39:56 pm »
Hello,
I want to send "Hello World" to UDP server but with fixed size so I did:
socket.send("Hello World",256,udpServer1,port);
 
It send packet with size 256 byte but it fill empty part with random character but I need blank with in hex show I get 0000.

I use winSniff to check packets structure.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Packet with fixed size
« Reply #1 on: February 20, 2013, 12:51:56 pm »
It's not magic, if you want to send a 256 characters long string padded with zeroes, you must create this string.

Sending a string with less characters than the given size causes an undefined behaviour.
Laurent Gomila - SFML developer

Hamed

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Packet with fixed size
« Reply #2 on: February 23, 2013, 04:43:19 am »
I have hex code of this package can I convert it to string and send it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Packet with fixed size
« Reply #3 on: February 23, 2013, 09:37:12 am »
You can do whatever you want. If you a have a specific problem, please be more precise about it.
Laurent Gomila - SFML developer

 

anything