C++ SFML TCP套接字不';不要等待数据
代码在这里C++ SFML TCP套接字不';不要等待数据,c++,network-programming,sfml,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;
#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;
}
}
#包括
#包括
使用名称空间std;
int main(int argc,char*argv[]){
char mode=*argv[1];
如果(模式==(字符)“-s”){
sf::数据包接收消息;
sf::TcpListener TcpListener;
sf::TcpSocket恶劣;
tcpListener.接受(包括);
inClient.接收(recMessage);
cout我将模式更改为std::string并取出了字符
if语句现在运行如果我遇到更多问题,我将提出另一个问题提示:mode==(char)“-s”
不正确,不会执行您期望的操作。用于比较字符串。或者,您知道,使用。