C
C#ā€¢15mo ago
Reversal

ā” 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
Jimmacle
Jimmacleā€¢15mo ago
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
MODiX
MODiXā€¢15mo ago
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!
Reversal
ReversalOPā€¢15mo ago
Is it possible to share multiple .cs files in one link?
Jimmacle
Jimmacleā€¢15mo ago
i think you can put multiple tabs in a paste, but if it's a lot you might want to put it on github
Reversal
ReversalOPā€¢15mo ago
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
Jimmacle
Jimmacleā€¢15mo ago
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?
Reversal
ReversalOPā€¢15mo ago
This is basically all for tcp udp feels also slow
Jimmacle
Jimmacleā€¢15mo ago
"feels slow" is not something i can work with
Reversal
ReversalOPā€¢15mo ago
If you have 5 minutes I'll provide you a short video
Jimmacle
Jimmacleā€¢15mo ago
you also didn't share both sides of this solution, the client has code too
Reversal
ReversalOPā€¢15mo ago
I have shared you both sides
Jimmacle
Jimmacleā€¢15mo ago
there's only one file in that paste
Reversal
ReversalOPā€¢15mo ago
The link I gave has 3 files
Jimmacle
Jimmacleā€¢15mo ago
it does not
Reversal
ReversalOPā€¢15mo ago
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
Reversal
ReversalOPā€¢15mo ago
BlazeBin - svsjlfctlivw
A tool for sharing your source code with the world!
Reversal
ReversalOPā€¢15mo ago
BlazeBin - fofksofnepnl
A tool for sharing your source code with the world!
Reversal
ReversalOPā€¢15mo ago
============================ It's probably the issue of my laptop's cpu who can't handle it. I've switched it up and it looks fine
Kouhai
Kouhaiā€¢15mo ago
I don't think this code should cause any high cpu usage even on a laptop
Omnissiah
Omnissiahā€¢15mo ago
how are you observing the clicks
Kouhai
Kouhaiā€¢15mo ago
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 Kek
Omnissiah
Omnissiahā€¢15mo ago
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)
Buddy
Buddyā€¢15mo ago
Buddy
Buddyā€¢15mo ago
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.
Sam
Samā€¢15mo ago
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
Reversal
ReversalOPā€¢15mo ago
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
Iron
Ironā€¢15mo ago
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.
Kouhai
Kouhaiā€¢15mo ago
Sorry if it came across that way, I didn't really intended to shame anyone, just was an observation!
Jimmacle
Jimmacleā€¢15mo ago
you have to use chatgpt carefully because it will gladly make up random crap to answer you
Iron
Ironā€¢15mo ago
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.
Accord
Accordā€¢15mo ago
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.
Reversal
ReversalOPā€¢7mo ago
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?
No description
Reversal
ReversalOPā€¢7mo ago
BlazeBin - jxcqfedumvvx
A tool for sharing your source code with the world!
Omnissiah
Omnissiahā€¢7mo ago
string message = $"{keyCode}";
byte[] data = Encoding.ASCII.GetBytes(message);
string message = $"{keyCode}";
byte[] data = Encoding.ASCII.GetBytes(message);
šŸ˜ really
Reversal
ReversalOPā€¢7mo ago
Hmm ?
Omnissiah
Omnissiahā€¢7mo ago
why are you sending a string send the raw bytes
Want results from more Discord servers?
Add your server