Solved how can i know that my LAN is working or not
-
-
@victor-wang You're still doing it wrong. Please read documentation - I posted the links.
If you want to use IP address you need to pass http://doc.qt.io/qt-5/qhostaddress.html as parameter not a string. -
@jsulm
Is that mean i have to set address first like this?hostaddress->setAddress(192.168.120.115);
Then connect it like this?
socket->connectToHost(hostaddress,PT_lanHostPort);
Is that right?
-
@victor-wang Yes
socket->connectToHost(QHostAddress("192.168.120.115"), PT_lanHostPort);
Why do you allocate everything on the heap with new? hostaddress can be just a local variable:
QHostAddress hostaddress("192.168.120.115"); socket.connectToHost(hostaddress, PT_lanHostPort); // No need to allocate socket on the heap with new as well!
-
-
@victor-wang It is not a Qt thing, it is C++.
It should actually work even if authentication is required. Is port number correct? Can you ping this IP? -
@jsulm
I'm sure that i can ping this IP address!
But i don't know how to check the port number. -
@victor-wang Well, you should know on which port your server is listening.
-
A socket connection to the server is always possible, even if you need a username and a password to authenticate for using its service.
In case you do not provide any login data or incorrect login data the server is still responding to your request.- What kind of service is running on this host?
- How do you usually connect to this host?
-
-
@victor-wang Check your server configuration. How, depends on what server it is (Apache, NGNX,...). Or ask the people who manage the server.
-
@jsulm
I've change the port and it success!
Thank you so much !
I think i need to practice more. -
@victor-wang Good!
And don't forget to read documentation :-) -
@jsulm You are a patience ninja and a Gentleman. Great to see still people like you in these forums!!!
-
@Julian-Guarin Thanks! :-)