SFML TCP套接字不等待数据

时间:2015-05-15 17:49:26

标签: c++ network-programming sfml

代码在这里

#include <SFML/Network.hpp>
#include <iostream>

using namespace std;


int main(int argc, char* argv[]) {
    char mode = *argv[1];

    if(mode == (char) "-s") {
        sf::Packet recMessage;

        sf::TcpListener tcpListener;

        sf::TcpSocket inClient;

        tcpListener.accept(inClient);

        inClient.receive(recMessage);

        cout << recMessage << endl;
    }
}

当使用-s运行时,我希望程序在收到数据之前不要关闭,但是当我运行程序时它会关闭。

1 个答案:

答案 0 :(得分:0)

我将模式更改为std :: string并取出了char castings

if if语句现在运行,如果我遇到更多麻烦我会再提出一个问题

相关问题