Comments (11)
Yes, of course it could be improved; can't everything? I'm glad it works; sorry about the high CPU usage. The sledgehammer that the existing implementation makes available you've already identified is the spinwait delay which in some places can be optionally passed in. If the entry points aren't sufficient for your needs you're welcome to branch, extend and submit a pull request and so long as you don't break anything incumbent I'll merge it in. Even if it does break something I'll consider it but it might take longer to complete the merge :)
from telnet.
from telnet.
Pros; simplicity and cross framework/platform reusability
Cons; it's all still pretty synchronous atm despite the half way house async spin stuff which was enough to facilitate keeping a simple UI responsive, per my use cases; but is going to come to it's knees before long if you start running multiple parallel threads per your use case... Delay and sleep are little better than each other; looking in to the event model and using callbacks to respond to activity is probably a good route to pursue; but that is likely to quickly break across the frameworks and certainly wouldn't be a trivial pursuit.
from telnet.
Thanks, but not sure I understand your first reply.
Is there a configurable "sleep/delay" setting I could use to lower the CPU load (and pay with responsiveness, as I am not using a UI and therefore less sensitive) without changing the code?
from telnet.
Sorry for misleading, you're right. I checked out the code while merging in the LineTerminator PR and seems like you would need a code change to alter the DefaultTimeoutMs (depending on framework version you're using). Wouldn't be too hard to add in an overload or two (or more for others with same problem :) and would definitely be a step in the right direction even if it would still be a bit of a sledgehammer...
from telnet.
from telnet.
from telnet.
In my latest Pull Request #35 I increased the delay between reads from 1ms to 16ms. I did this because most operating systems do not measure ticks below 10ms which can cause sleep times of 1ms to be treated as zero. That seems to help on receiving packets but the largest performance boost I was able to produce was from buffering writes and changing all internal write operations from .WriteByte to .WriteAsync. This vastly reduced TCP overhead.
Read about double buffered TCP writes here:
http://www.stuartcheshire.org/papers/nagledelayedack/
If you would like to beta test my new version you can get it here:
https://github.com/A9G-Data-Droid/Telnet/releases/tag/0.8.2
from telnet.
from telnet.
@iftahb @A9G-Data-Droid guys; sorry had to come on and reply that I likewise appreciate all done; but I've got a day job & life too and the amount of effort that's gone in to all the improvements suggested is going to take time to review, build and publish which I've not had in the last few days; sorry. Bear with me please... In the meantime feedback on the beta release would be most helpful to both of us :)
from telnet.
@iftahb I'm not sure. My code doesn't connect to more than one host at a time but I hope you see a performance boost from my improvements. Please let me know if it helps.
from telnet.
Related Issues (20)
- Weird response from server HOT 1
- LiteGuard dependency conflict HOT 7
- [Question] Added Telnet Server to main project HOT 2
- Console.write in TryLoginAsync intentional? HOT 3
- Particular Example Request HOT 1
- CancellationToken functionality at creating Client Instance HOT 1
- TryLoginAsync timeout HOT 1
- TryLoginAsync attempt 2 HOT 3
- Sending UTF-8 characters in XML file HOT 3
- Remove Console.Write() from TerminatedReadAsync HOT 2
- TelnetServer? HOT 2
- Guaranteed to Read all text when no terminated string and independently from timeout HOT 6
- Confusing use of Timeout HOT 1
- No stated dependency on Microsoft.VisualStudio.Threading, Version=17.3.0.0 HOT 6
- Update function TryLoginAsync with Regex terminator string HOT 1
- Client keeps disconnecting HOT 2
- Telnet Login HOT 1
- How to read UTF8 strings? HOT 2
- How to filter out remote echo of my commands HOT 1
- DONT/WONT case should read byte to the end of IAC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telnet.