GLBasic forum

Main forum => GLBasic - en => Topic started by: Hemlos on 2010-Jan-13

Title: Telnet?
Post by: Hemlos on 2010-Jan-13
Is it possible to use NETJOINGAME(server$, tcp_port%) to join a telnet session?
Title: Re: Telnet?
Post by: Moru on 2010-Jan-13
As long as you don't want to do anything fancy with telnet, using the socket commands to connect should not be very difficult.
Title: Re: Telnet?
Post by: FutureCow on 2010-Jan-14
What fancy stuff with telnet would be difficult with the socket commands? I can't think of anything - it should be straightforward.
Title: Re: Telnet?
Post by: Hatonastick on 2010-Jan-14
It's not hard to do actually.  I built in the ability for Telnet negotiation in my (no, not this again, why doesn't he shut up?  =D) old MUD server.  As with most of those old protocols, the easiest way to handle it (server or client) is with a simple FSM (Finite State Machine) setup.  If you don't know how FSM's work, there are plenty of examples (or used to be) online or in various older C programming books (basically a loop with a long, long case statement with positions that you jump to depending on the current 'state').  There may be a more elegant solution in GLB, but I still think like an old C programmer so I'm probably not the person to answer that one.  Anyway all the old network protocols are fairly simple when you break them down.  Basically a process of questions and answers that go between the server and client.

Be aware that the Microsoft Telnet client _does not_ act like a real telnet client.  It's missing half the protocols and doesn't react the way it should when sent certain queries.  I came up with a way to identify whether or not someone was using the MS version and then handling it's oddities with various hard-coded solutions, but don't ask me to tell you how as I don't remember -- theres likely more elegant solutions (if needed) around these days anyway if you check around.  This was a long, long time ago though so no idea if their current client (do Vista and Windows 7 have one?) behaves more appropriately.  If you are using Linux or OSX though, you are safe. :)

Edit:  Wow, once again I do a brilliant job of answering questions that are asked in my head rather than the ones the OP _actually_ asked.  Sorry about that.  I'll leave this here just in case there is something useful in my reply, but will delete later if there isn't.
Title: Re: Telnet?
Post by: Hemlos on 2010-Jan-14
Thanks for all the informative replies, i appreciate it.