Skip to content

Instantly share code, notes, and snippets.

@robertripoll
Last active September 23, 2020 18:08
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save robertripoll/6394321573dc0791dff9 to your computer and use it in GitHub Desktop.
Save robertripoll/6394321573dc0791dff9 to your computer and use it in GitHub Desktop.
Telnet Server C#
@robertripoll
Copy link
Author

@BruceGreene I just made a revision that contains fixed various issues which happened when the client removed a character with backspace and so on.

@jvanlangen
Copy link

jvanlangen commented Oct 6, 2017

TryGetValue won't raise an exception when the key is not found, it will return false:

    private TelnetServerClient getClientBySocket(Socket clientSocket)
    {
        TelnetServerClient c;

        try
        {
            clients.TryGetValue(clientSocket, out c);
        }

        catch
        {
            c = null;
        }

        return c;
    }
	
	---
	
    private TelnetServerClient getClientBySocket(Socket clientSocket)
    {
        TelnetServerClient c;
        if(clients.TryGetValue(clientSocket, out c))
        return c;
    else
        return null;
    }

@jvanlangen
Copy link

C# and camelCase... :*-(

@robertripoll
Copy link
Author

robertripoll commented Dec 1, 2017

@jvanlangen That's absolutely right TryGetValue, returns a boolean to specify whether the value was found by the passed key. I just made a revision to fix that.

@xmedeko
Copy link

xmedeko commented Oct 12, 2018

+1 Nice code, thanks. What about to convert it to a small repo? Also, I agree with @jvanlangen that the methods starting with lower case are not according to C# standard.

Also from my cygwin client I had to change:

  • line end add condition: || (data[0] == 0x0D && data[1] == 0x00))
  • backspace is 0x7F: if (data[0] == 0x08 || data[0] == 0x7F)

@vano-creator
Copy link

hi, i want ubiquit system reboot one click by telnetserver. can you tell me how make it c# code?

@ychen5osram
Copy link

Hi. Thanks for the code. Would you mind creating a repo and attach a license to it so that people can use it without fear? Appreciated!

@robertripoll
Copy link
Author

This gist has been moved to a GitHub repository: https://github.com/UngarMax/TelnetServer

@robertripoll
Copy link
Author

robertripoll commented Sep 19, 2020

Hi. Thanks for the code. Would you mind creating a repo and attach a license to it so that people can use it without fear? Appreciated!

@ychen5osram Done! https://github.com/UngarMax/TelnetServer

@ychen5osram
Copy link

Hi. Thanks for the code. Would you mind creating a repo and attach a license to it so that people can use it without fear? Appreciated!

@ychen5osram Done! https://github.com/UngarMax/TelnetServer

thx a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment