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

Author Topic: Packet receives empty string  (Read 3178 times)

0 Members and 2 Guests are viewing this topic.

Dean404

  • Newbie
  • *
  • Posts: 4
    • View Profile
Packet receives empty string
« on: June 17, 2015, 06:57:11 pm »
string_to_send = "P";
packetSend << string_to_send << pointer_x << pointer_y;
                                globalMutex.unlock();
                                socket.send(packetSend);
Sending code
if (packetReceive >> new_building >> new_x >> new_y)
                {
                                        map[new_y][new_x] = new_building;                                      
                                        SomethingChanged = true;
                }
Receiving code.
And new_building equals nothing. Please, tell me, what am I doing wrong here. new_x and new_y are all right, though.

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Packet receives empty string
« Reply #1 on: June 17, 2015, 09:48:41 pm »
I think the new_building has to be char *

Dean404

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Packet receives empty string
« Reply #2 on: June 17, 2015, 09:58:46 pm »
I think the new_building has to be char *
Nope, it's still nothing.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10991
    • View Profile
    • development blog
    • Email
Re: Packet receives empty string
« Reply #3 on: June 17, 2015, 10:05:53 pm »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dean404

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Packet receives empty string
« Reply #4 on: June 17, 2015, 10:13:25 pm »
Here's the separate programm, that has to send std::string through packet:
(click to show/hide)
And here is the result:
(click to show/hide)
(The last line is "Press any button to continue..." in russian)

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Packet receives empty string
« Reply #5 on: June 18, 2015, 02:45:50 am »
your code works fine on my computer.

Dean404

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Packet receives empty string
« Reply #6 on: June 18, 2015, 03:05:34 am »
Oh lol, i am so stupid, forgot to add sfml-network.lib. Working fine now.

 

anything