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

Author Topic: [Problem fixed] Receiving more Data then sent  (Read 4065 times)

0 Members and 1 Guest are viewing this topic.

Zerxes

  • Newbie
  • *
  • Posts: 5
    • View Profile
[Problem fixed] Receiving more Data then sent
« on: June 09, 2009, 03:28:28 am »
I have a Problem with Receiving directly after making a connection.
The Data I receive is not broken, but there are 4 Byte Data before my sent Data...

Client-Side Code:
Code: [Select]
   NetPacket.Append( &iBuild, sizeof(sf::Uint32) );
    NetPacket.Append( &LocalInfo, sizeof(s_InfoPlayer) );
    m_Socket.Send( NetPacket );


Server-Side Code:

That works:
Code: [Select]

        if (m_Client.Receive( (char*)&SomeData, sizeof(sf::Uint32), iCount) != sf::Socket::Done) { return; }
        if (m_Client.Receive( (char*)&iBuild, sizeof(sf::Uint32), iCount) != sf::Socket::Done) { return; }
        if (m_Client.Receive( (char*)&PlayerInfo, sizeof(s_InfoPlayer), iCount) != sf::Socket::Done) { return; }


That dont works:
Code: [Select]

        if (m_Client.Receive( (char*)&iBuild, sizeof(sf::Uint32), iCount) != sf::Socket::Done) { return; }
        if (m_Client.Receive( (char*)&PlayerInfo, sizeof(s_InfoPlayer), iCount) != sf::Socket::Done) { return; }


Greetings

Zerxes

  • Newbie
  • *
  • Posts: 5
    • View Profile
[Problem fixed] Receiving more Data then sent
« Reply #1 on: June 09, 2009, 04:09:26 am »
Problem fixed.

Client-Side Code:
Code: [Select]

    m_Socket.Send( (char*)&iBuild, sizeof(sf::Uint32) );
    m_Socket.Send( (char*)&LocalInfo, sizeof(s_InfoPlayer) );

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[Problem fixed] Receiving more Data then sent
« Reply #2 on: June 09, 2009, 07:58:44 am »
sf::Packet has its own format (the 4 bytes prepended to the data are its size). If you send a packet you have to receive a packet, I can't see why you're receiving it as raw data.
Laurent Gomila - SFML developer