Home > other >  Says "Socket QTCPsocket for connection to the server operation timed out"
Says "Socket QTCPsocket for connection to the server operation timed out"

Time:10-04

Server:
The connect (UI - & gt; Enter, SIGNAL (clicked ()), and this, SLOT (enter ()));
Void Tuser: : enter () {
The UI - & gt; IpEdit - & gt; SetEnabled (false);
The UI - & gt; PortEdit - & gt; SetEnabled (false);
The UI - & gt; The label - & gt; SetText (" both Please wait for another player... ");
Int x=UI - & gt; PortEdit - & gt; The text (). ToInt ();
Lserve - & gt; Listen (QHostAddress: : Any, x);
The connect (lserve, SIGNAL (newConnection ()), and this, SLOT (start ()));
}
Void Tuser: : start () {
//qDebug () & lt; <" Yes ";//no message printed, signal not launch
Srand ((int) time (0));
Note=rand () % 2;
The init ();//0: black; 1: white
Two=lserve - & gt; NextPendingConnection ();
The connect (two, SIGNAL (readyRead ()), and this, SLOT (readmessage ()));
Sendmessage (1);
}

Then check the client:
Void Ouser: : enter () {
One - & gt; ConnectToHost (QHostAddress (UI - & gt; PipEdit - & gt; The text ()), the UI - & gt; PportEdit - & gt; The text (). ToInt ());
if(! One - & gt; WaitForConnected (30000)) {
QDebug () & lt; }
The else {
QDebug () & lt; <" Yes ";
}
The connect (one, SIGNAL (readyRead ()), and this, SLOT (readmessage ()));
}

Questions about the function name is the same... Tuser and Ouser is two project, so is the graph save trouble,
Is related to network status? I set time is 30 seconds or the problem
  • Related