ā TCP vs UDP
I made a program that performs a left mouse click when a message is received through TCP or UDP.
My question is why is it so clunky? I sometimes perform 2 mouse clicks in some very short intervals. Is there something better way than TCP/UDP?
36 Replies
you will have to quantify "clunky" and share all your code, because it is ridiculously unlikely that the transport protocol is to blame
for example, i'm working on an embedded system that talks to a PC over TCP and the delay between request and response is imperceptible
$paste
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Is it possible to share multiple .cs files in one link?
i think you can put multiple tabs in a paste, but if it's a lot you might want to put it on github
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
there's nothing there that can be slow that i can see
have you eliminated the possibility that some other part of your code is slow?
This is basically all for tcp
udp feels also slow
"feels slow" is not something i can work with
If you have 5 minutes I'll provide you a short video
you also didn't share both sides of this solution, the client has code too
I have shared you both sides
there's only one file in that paste
The link I gave has 3 files
it does not
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
BlazeBin - svsjlfctlivw
A tool for sharing your source code with the world!
BlazeBin - fofksofnepnl
A tool for sharing your source code with the world!
============================
It's probably the issue of my laptop's cpu who can't handle it.
I've switched it up and it looks fine
I don't think this code should cause any high cpu usage even on a laptop
how are you observing the clicks
They seem to be calling
GetAsyncKeyState
in an infinite loop, but they have a 10ms sleep so the CPU won't be used that much
It honestly looks like the code was ChatGPT generated the detecting part is using that api, but i mean to ask if he's looking at the clicks (let's say he's using rdp or vnc, or a stream; it could make sense that it's delayed) or what (maybe it's a game, and the game is slow, i don't know)
UDP is also connectionless, but isn't reliable. UDPs latency is significantly lower than TCPs.
TCP requires a connection but is reliable.
Reliable in terms of packets always arrive in order and well, arrives.
You need to set socket.nodelay = true
Nagles algorithm is trying to wait for more data to send in a single payload, because sending tiny packets is very inefficient especially with TCP
Well with the poor resources and documentation i had to find some solution ...
No shame in using chat gpt tbh
Anyway the clicks on my laptop like I said on my initial question feel like they are pressed twice. It doesn't feel smooth. But it looks like it's working fine on my pc. So ... I think my laptop is just not strong tbh
Ok, interesting. I'll take a look on it
So weird.. It's working fine today. Not sure if it was my internet connection or the nodelay = true. I switched back to turning off the nodelay and it still works fine now
ChatGPT is actually very good to learn, when i dont understand something i usually ask the bot to let me know what im doing wrong and why, it explains it just like a teacher would.
Sorry if it came across that way, I didn't really intended to shame anyone, just was an observation!
you have to use chatgpt carefully
because it will gladly make up random crap to answer you
Yes but for example me. I always try my own way first , then if i get stuck i might ask ai just like i ask you guys sometimes like hey why is this doing this. But i also ask the ai to explain every single line to me , like a teacher basically is my opinion xD but just straight copy and pasting is not good then you will not learn.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Hello gentlemen, It has been a while isn't it? Let me give you a tl;dr with the new info in bold so you don't have to go through the history again.
I created an application that performs a left mouse click on my other computer when I press a key on my keyboard through TCP/UDP. The code is somewhere above. When spam clicking / pressing a key I get somewhat the same delay in between clicks as seen in the picture. But when performing real clicks the delay in between clicks fluctuate alot. Does anyone might know the reason why?
BlazeBin - jxcqfedumvvx
A tool for sharing your source code with the world!
š
really
Hmm ?
why are you sending a string
send the raw bytes