Solved Fortune examples (client and server)
-
@Diarby
Hi
That is not a good port.
You could use some random one for the server app and clients would always try that.
But you might be blocked by firewalls. -
Hi
https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Ports are normally used pr service the server provides.
You are free to use one not taken.
BUT can u trust the users to open ports? -
@mrjj
Hi. I'd try to scan all ports (from 1 to 65535) until I found the exact one. For each, I'll try a connection.
Is this solution suitable ? -
@Diarby
well if user run some local webserver or other service it might not work but
yes it could work.You do understand that most home routers comes with most ports disabled ?
and wont allow access unless open in router.So if you deployment involves random user around the world and u try to connect to them from outside, you
might get issues. -
@mrjj
Thanks for this link. I was writing when you sent it. Please give me time to read it and I'll be back tomorrow -
Hi normally the users are running the client that connects to a known IP+port to talk
to server. It sounds like you plan to do the reverse? -
@mrjj
Hi
I just finished reading the wikipedia article. From your last post, I agree to your opinion : IP + port is known by clients.
I was disturbed by Fortune Server which changes port on every launch.
A subsidiary question, why Qt let newbies learn client/server programming with this example ? -
@Diarby said in Fortune examples (client and server):
I was disturbed by Fortune Server which changes port on every launch.
Just change
if (!tcpServer->listen())
toif (!tcpServer->listen(QHostAddress::Any,13008))
in the server then you can be 100% sure the port will be 13008A subsidiary question, why Qt let newbies learn client/server programming with this example ?
I know, it's proper garbage.
Try page 323 (341 of the PDF) of C++ GUI Programming with Qt4. It's a bit old andQDataStream
evolved and made everything easier but it's still better than the Fortune example -
@Diarby
Ok, so it will not be reversed in your case?
The Fortune examples just teach how to use the Qt classes.
Its not really up to the task of teaching basic networking. ( or not included at least)
But there are tons of info about that on net. -