Just started to learn the programming of networks, sockets, and so on. I downloaded a simple server from this article . In the on_starting_clicked() slot, replaced the string
tcpServer->listen(QHostAddress::Any, 33333) on
tcpServer->listen(QHostAddress::LocalHost, 33333) and wrote a simple program that should connect to this server and send exactly 1 message. Her code is:
int main(int argc, char *argv[]) { QCoreApplication z(argc, argv); QTcpSocket a; a.open(QIODevice::WriteOnly); a.bind(QHostAddress::LocalHost, 33333); a.write(QByteArray("rferfergregerger")); return z.exec(); } The problem is that the program does not connect to the server and does not send anything to it. Question: how to make the program send messages to the server? What am I doing wrong and how should I do it? What does QHostAddress::Any generally mean? How do other computers connect to the server? Is it possible to send structures through sockets and, if so, how to do it using QTcpSocket?