Sponsored Content
Top Forums Programming How to program a telnet client? Post 13361 by thinker130 on Wednesday 16th of January 2002 03:08:22 AM
Old 01-16-2002
the source file(the second half tel_cli.c and tel_cli.h)

case WONT:
break;
case SB:
printf("ch is SB\n");
sleep(5);
if (lcOption == TSPEED)
{
printf("RECV IAC SB TERMINAL SPEED SEND (32)\n");
printf("%d%d%d\n", rbuf[i], rbuf[i + 1], rbuf[i + 2]);
//i = i + 3;
sleep(5);
bzero(gsSendMsg, LINELEN);
sprintf(gsSendMsg, "%c%c%c%c%d%d%d%d%c%c\n", IAC, SB, TSPEED, IS, 38400 >> 8, (38400 & 0xFF), 38400 >> 8, (38400 & 0xFF), IAC,SE);
write(li_sock, gsSendMsg, strlen(gsSendMsg));
}
if (lcOption == NEW_ENVIRON)
{
printf("RECV IAC SB NEW-ENVIRON SEND (39)\n");
printf("%d%d%d\n", rbuf[i], rbuf[i + 1], rbuf[i + 2]);
//i = i + 3;
sleep(5);
bzero(gsSendMsg, LINELEN);
sprintf(gsSendMsg, "%c%c%c%c%c%c\n", IAC, SB, NEW_ENVIRON, IS, IAC, SE);
write(li_sock, gsSendMsg, strlen(gsSendMsg));
}

if (lcOption == TERMINAL)
{
printf("RECV IAC SB TERMINAL TYPE SEND (24)\n");
printf("%d%d%d\n", rbuf[i], rbuf[i + 1], rbuf[i + 2]);
//i = i + 3;
sleep(5);
bzero(gsSendMsg, LINELEN);
sprintf(gsSendMsg, "%c%c%c%c%s%c%c\n", IAC, SB, NEW_ENVIRON, IS,"ANSI", IAC, SE);
write(li_sock, gsSendMsg, strlen(gsSendMsg));
printf("okokok\n");
bzero(gsSendMsg, LINELEN);
sprintf(gsSendMsg, "%c%c%c\n", IAC, DODO,ECHO_ON);
write(li_sock, gsSendMsg, strlen(gsSendMsg));
printf("okokok\n");
}
i = i + 3;
break;

default:
printf("ch is other character\n");
break;
}

}
else
{
//printf("ch isn't IAC, there are maybe some errors occur!\n");
i++;
}
}
}
}



tel_cli.h:

//telnet command code
#define IAC 255
#define DODO 253
#define DONT 254
#define WILL 251
#define WONT 252
#define SB 250
#define SE 240
#define IS '0'
#define SEND '1'
#define INFO '2'
#define VAR '0'
#define VALUE '1'
#define ESC '2'
#define USERVAR '3'

//option name and id
#define ECHO_ON 1
#define GO_AHEAD 3
#define STATUS 5
#define TIMER 6
#define TERMINAL 24
#define NAWS 31
#define TSPEED 32
#define FLOW 33
#define LINEMODE 34
#define XDISPLOC 35 // X Display Location
#define OLD_ENVIRON 36 // Old - Environment variables
#define AUTH 37
#define NEW_ENVIRON 39
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using telnet client from MacOSX's command line terminal

I'm completely new to Unix, but familiar with Mac OSX. I've just discovered the command line terminal feature of this new OS and I'm trying to learn how to telnet into my host's server to change permissions to allow executable cgi scripts for my website. Is there anyone who might be able to... (2 Replies)
Discussion started by: tylerl
2 Replies

2. Programming

Telnet client IP determination

I have configured my firewall to allow only five remote IP's to connect to my server. Upon connection...i would like to automate the Xsession functions for authorized IP's. Mainly, $DISPLAY of the environment to the client. I understand that the "gethostbyaddr" function is capable of this.... (0 Replies)
Discussion started by: thomas.jones
0 Replies

3. Programming

Does Telnet client library exist ?

Hello, I'm new user in this forum, and i'm french ... so excuse me for my english :) In fact, I've to manage several network equipments which can be only configured with the telnet protocol. But using the standalone telnet tool, it's too long and hard. So I'd like to known if a Telnet... (0 Replies)
Discussion started by: aho
0 Replies

4. UNIX for Dummies Questions & Answers

IP address of telnet client

Hi, I am using the telnet client on windowsNT to access the Unix system. I want to find out the IP address of the telnet client from the server side. The reason is I want to set the DISPLAY environment variable when the user is logged on. Is there anyway that the the Unix server can... (1 Reply)
Discussion started by: vtran4270
1 Replies

5. UNIX for Dummies Questions & Answers

how to launch program though telnet

I have launched telnet on nt and have connected to a unix server, I'm trying to run a program on the unix server which will launch a gui, but when I try to launch it I get the message "display not set\n" "By default set it to 0.0" I can sit down at the unix machine and launch the program with... (3 Replies)
Discussion started by: cbachman
3 Replies

6. Programming

Client - server program

i came acors this coding when surfin the net.this code works perfectly.but as i am new to this socket programming i need sm coments quoted on it or explanation regarding this source code. i have prb understanding the server.c i have posted it below can u guys help me !!!! cheerZ The... (4 Replies)
Discussion started by: mathu
4 Replies

7. Programming

Server client program

hi guys, I need the code for a server client registration form.The server must ask for authentication .Then the client would send in data. This is stored in a file .The server sends back a receipt to the client as part of the payment done. plz can some 1 get me the code... (9 Replies)
Discussion started by: pip3r
9 Replies

8. Programming

SFTP client program

can u help me? i need the program code in C to perform Simple File Transfer in linux.in this forum i found the server program,inw i need the client program ASAP. Thanx. (1 Reply)
Discussion started by: harshi
1 Replies

9. UNIX for Advanced & Expert Users

difference between logging into unix through f-secure ssh client and telnet

hi, what is the difference between logging into unix through f-secure ssh client and telnet is there any more security check is involved can any one explain thanks in advance (1 Reply)
Discussion started by: trichyselva
1 Replies

10. Linux

telnet client and logs

Hello everyone. I have a script that telnets into a linux workstation and restarts a service, while logging the session to a file. I'm kind of new to linux so when I was using windows I would capture something like windows cli: telnet xxx.xxx.xxx.xxx -f c:/capture.log ... # /sbin/service... (3 Replies)
Discussion started by: Elyas_cr
3 Replies
TELNETD(8)						      System Manager's Manual							TELNETD(8)

NAME
telnetd - DARPA TELNET protocol server SYNOPSIS
/usr/libexec/telnetd DESCRIPTION
Telnetd is a server which supports the DARPA standard TELNET virtual terminal protocol. Telnetd is invoked by the internet server (see inetd(8)), normally for requests to connect to the TELNET port as indicated by the /etc/services file (see services(5)). Telnetd operates by allocating a pseudo-terminal device (see pty(4)) for a client, then creating a login process which has the slave side of the pseudo-terminal as stdin, stdout, and stderr. Telnetd manipulates the master side of the pseudo-terminal, implementing the TELNET protocol and passing characters between the remote client and the login process. When a TELNET session is started up, telnetd sends TELNET options to the client side indicating a willingness to do remote echo of charac- ters, to suppress go ahead, and to receive terminal type information from the remote client. If the remote client is willing, the remote terminal type is propagated in the environment of the created login process. The pseudo-terminal allocated to the client is configured to operate in "cooked" mode, and with XTABS and CRMOD enabled (see tty(4)). Telnetd is willing to do: echo, binary, suppress go ahead, and timing mark. Telnetd is willing to have the remote client do: binary, ter- minal type, and suppress go ahead. SEE ALSO
telnet(1C) BUGS
Some TELNET commands are only partially implemented. The TELNET protocol allows for the exchange of the number of lines and columns on the user's terminal, but telnetd doesn't make use of them. Because of bugs in the original 4.2 BSD telnet(1C), telnetd performs some dubious protocol exchanges to try to discover if the remote client is, in fact, a 4.2 BSD telnet(1C). Binary mode has no common interpretation except between similar operating systems (Unix in this case). The terminal type name received from the remote client is converted to lower case. The packet interface to the pseudo-terminal (see pty(4)) should be used for more intelligent flushing of input and output queues. Telnetd never sends TELNET go ahead commands. 4.2 Berkeley Distribution November 16, 1996 TELNETD(8)
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy