C
C#9mo 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
Jimmacle9mo 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
MODiX9mo 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
Reversal9mo ago
Is it possible to share multiple .cs files in one link?
Jimmacle
Jimmacle9mo 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
Reversal9mo ago
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
Jimmacle
Jimmacle9mo 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
Reversal9mo ago
This is basically all for tcp udp feels also slow
Jimmacle
Jimmacle9mo ago
"feels slow" is not something i can work with
Reversal
Reversal9mo ago
If you have 5 minutes I'll provide you a short video
Jimmacle
Jimmacle9mo ago
you also didn't share both sides of this solution, the client has code too
Reversal
Reversal9mo ago
I have shared you both sides
Jimmacle
Jimmacle9mo ago
there's only one file in that paste
Reversal
Reversal9mo ago
The link I gave has 3 files
Jimmacle
Jimmacle9mo ago
it does not
Reversal
Reversal9mo ago
BlazeBin - gcxxpwksacdk
A tool for sharing your source code with the world!
Reversal
Reversal9mo ago
BlazeBin - svsjlfctlivw
A tool for sharing your source code with the world!
Reversal
Reversal9mo ago
BlazeBin - fofksofnepnl
A tool for sharing your source code with the world!
Reversal
Reversal9mo 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 /人◕ ‿‿ ◕人\
I don't think this code should cause any high cpu usage even on a laptop
WEIRD FLEX
WEIRD FLEX9mo ago
how are you observing the clicks
Kouhai /人◕ ‿‿ ◕人\
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
WEIRD FLEX
WEIRD FLEX9mo 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
Buddy9mo ago
Buddy
Buddy9mo 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
Sam9mo 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
Reversal9mo 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
Iron9mo 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 /人◕ ‿‿ ◕人\
Sorry if it came across that way, I didn't really intended to shame anyone, just was an observation!
Jimmacle
Jimmacle9mo ago
you have to use chatgpt carefully because it will gladly make up random crap to answer you
Iron
Iron9mo 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
Accord9mo 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
Reversal3w 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
Reversal3w ago
BlazeBin - jxcqfedumvvx
A tool for sharing your source code with the world!
WEIRD FLEX
WEIRD FLEX3w ago
string message = $"{keyCode}";
byte[] data = Encoding.ASCII.GetBytes(message);
string message = $"{keyCode}";
byte[] data = Encoding.ASCII.GetBytes(message);
😐 really
Reversal
Reversal3w ago
Hmm ?
WEIRD FLEX
WEIRD FLEX3w ago
why are you sending a string send the raw bytes
Want results from more Discord servers?
Add your server
More Posts