Sign in to follow this  

How do I send ANSI codes to Telnet, exactly?

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone! Here's how I'm sending my codes: (After I established a connection and received a character)
SDLNet_TCP_Send(csd, (void*) 0x1B, 1);	// Send ESC char
SDLNet_TCP_Send(csd, (void*) 0x01, 1);	// Send 0x01 (40x25 colors creen)
SDLNet_TCP_Send(csd, (void*) 0x42, 1);	// Green background
SDLNet_TCP_Send(csd, buffer, 1);	// Send my char

But only the last one gets sent! (On WinXP's Telnet client, it gets sent twice, so I'm using Win98's) Why is it? I have a feeling this is not how you do it... Any ideas? Thanks!

Share this post


Link to post
Share on other sites
You can't cast 0x1B to a void * and expect it to work.

I imagine that SDLNet_TCP_Send requires a pointer to a buffer. 0x1B is not a pointer to a buffer containing the value 0x1B, it's the value 0x1B itself. If you attempt to dereference this pointer it will certainly fail.

I'm really surprised your code doesn't crash.

Mark

Share this post


Link to post
Share on other sites
Hmm... Still not working...

Here's what I'm doing now:


char sm[5];

/* Function goes here, doesn't mess with sm at all */

sm[0] = (char) 0x1b;
sm[1] = '[';
sm[2] = '=';
sm[3] = (char) 4;
sm[4] = 'h';

SDLNet_TCP_Send(csd, sm, 5); // Send escape sequence
SDLNet_TCP_Send(csd, buffer, 1); // Send my char



By that I'm trying to change the screen mode to 320x200 color... Am I doing something wrong or what? Thanks!

PS: I'm using PuTTY on Win98.

Share this post


Link to post
Share on other sites
Assuming that is transmitted correctly, you're not going to find a basic telnet client that will give you any non-text modes. For that you'll probably need one of the old X clients. I seem to remember 'Exceed' being one of them, back from my long distant days on Sun Sparc stations. If a graphical mode is a requirement of your project, you should probably give up on the telnet/ANSI route.

Share this post


Link to post
Share on other sites
Yeah, I figured it out... :grin:
Now, how can I check which Telnet client the user is running? Because for example, Windows Telnet sends info when a character is pressed, but PuTTY only sends it when Enter is pressed! Do you know? Thanks!

Share this post


Link to post
Share on other sites
Putty sends the character as soon as you press the key. If you observe a difference, it must come from elsewhere -- unless you somehow have set Putty to "line mode" or something similar.

Detecting which terminal emulation is at the other end is pretty hard, even though it's been a problem for 30 years. The best you can do is use the TELNET standard for terminal type negotiation (it's among the TELNET protocol escape codes) and hope the client complies.

Or just ask the user when they log on.

Share this post


Link to post
Share on other sites

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this