Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Ethernet communication between RPi and local PC
As the title suggest i am trying to establish communication between RPi and local PC. so far i have not come across any documentation related to that. I have read about QTCPSOCKET but i dont have clear idea of how to do this. this is all completely new please help.
seem like a good place to start.
If you use QtCreator, then they are part of the ready to compile examples in it.
MrShawn last edited by
Search "TCP server Voidrealms" on youtube. That might help get you started as well.
thank you for your replies.
i followed the tutorial at bogotobogo and was able to establish connection. Now in my code following line:
makes the server to listen to all connections on port 1234. how to make it always listen to only one connection (local PC)?
i tried that before and I get "no connection could be made because the target machine actively refused it." at client side.
Any and AnyIPv4 work normally and using ipv4 at client side by the way. Still working on server to listen only to PC.........
Still working on server to listen only to PC.........
Maybe you should rephrase your question. LocalHost means Server and Client run on the same machine.
It sounds like that is not what you want. What do you want then?
ok I get what you say.
I am able to create server at RPi which listens to connections and after serving first client ( PC ), it disconnects and waits for new connection. i want it to stay connected to the same client and not look for another connection.
i want it to stay connected to the same client
... then just make sure that not one side (PC or RPi) disconnects for some reason.
and not look for another connection.
So effectively you want to limit your server to one connection at a time. Looks like: https://stackoverflow.com/questions/35926188/qt-tcpserver-max-clients where the answer from peppe states:
"Do not call nextPendingConnection if you're already handling enough clients."
I think that is what you should do.
yes I agree, my code is exactly the same.
but if you remove nextpendingconnection line then they simply don't communicate. I tried to replace it with other member functions of QTcpServer but This piece of code is essential in the end.
what should i replace it with then?
If your re-read my post you will notice that I didn't say, you should remove or replace
I rather said, if you have enough clients, then don't accept further ones by not calling
nextPendingConnection(). In your case that would mean you call it only one time for the first connection.
ok, i understood what you said.