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

Author Topic: Using UDP sockets with graphics packet  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

Linuxxon

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - rasmus.linusson@gmail.com
    • View Profile
    • http://www.linuxxon.com
Using UDP sockets with graphics packet
« on: October 21, 2011, 06:30:37 pm »
When I send a regular packet containing an int and two strings between these two loops everything works fine.

Code: [Select]
sf::Packet Packet;
    sf::IPAddress IP;
    unsigned short Port;

    std::cout << "Waiting for clients..." << std::endl;
    Socket.Receive(Packet, IP, Port);
    std::cout << "Connection received!" << std::endl;

    int Type;

    if (Packet >> Type == 1)
    {
        std::string userName, Password;

        Packet >> userName >> Password;

        std::cout << "Username: " << userName << " Password: " << Password << std::endl;
    }

Code: [Select]
       sf::SocketUDP UDP;

        sf::Packet testPacket;
        int Type = 1;
        std::string userName = "00";
        std::string password = "00";

        std::cout << "Enter username: ";
        std::getline(std::cin, userName);
        std::cout << "Enter password: ";
        std::getline(std::cin, password);

        sf::IPAddress Address = "127.0.0.1";
        unsigned short portNr = 4639;

        testPacket << Type << userName << password;
        UDP.Send(testPacket, Address, portNr);
        std::cout << "Sent Login to " << Address << ":" << portNr << std::endl;


But when I have the same client code within a client rendering a window the socket doesen't go through to the server.

The client renders a single frame with a loaded image then pauses for input from user, that's the only difference between the client I want to use and this code...

So do anyone have an idea why this would be?