SFML UDPSockets错误发送

时间:2015-07-01 11:31:13

标签: sockets networking udp sfml

我正在尝试使用UDPSocket发送扩展数据包,似乎send函数返回4,根据http://www.sfml-dev.org/documentation/2.3/classsf_1_1UdpSocket.php表示“TCP套接字已断开连接”。我不知道我做了什么,特别是因为我使用UDP套接字而不是TCP。

packet << playerVariables;
    if (socket.send(packet, recipientAddress, recipientPort) != sf::Socket::Done)
    {
        std::printf("%d", socket.send(packet, recipientAddress, recipientPort));

    }
    else
    {
        std::printf("sent /n");
    }

这些是我对数据包的扩展

sf::Packet& operator <<(sf::Packet& packet, const playerStruct& player)
{
    return packet << player.xPos << player.yPos << player.health;
}

sf::Packet& operator >>(sf::Packet& packet, playerStruct& player)
{
    return packet >> player.xPos >> player.yPos >> player.health;

0 个答案:

没有答案