Solved

How can I communicate with Telnet Server?

Posted on 1998-07-21
1
175 Views
Last Modified: 2013-12-03
Hi
Recently,I should make some application that using telnet.
So I got some telnet client code that is very simple.

But I couldn't understand some part of this program that communicate wiht telnet server
Untill using of connect() function in the below of program example, I can understand.
Afterthat this program send some bytes to telnet server.

I thought that is some specification of telnet protocol, but I don't have any information about that
I marked that section in the program......Please take a look!
I need any kind of help....I am in a hurry
I appreciate all of help...

Here is parts of telnet client.

int connect_server(void)
{
gg=WSAStartup(0x0101,&ws);
if (gg!=0) {MessageBox(0,error_WSAStartup(WSAGetLastError()),"error",0);return -1;}

//SendMessage(0,hwndChk,0,(LPARAM) (LPSTR) "try to open socket");
s = socket(AF_INET,SOCK_STREAM,0);
if (s==INVALID_SOCKET) {MessageBox(0,error_socket(WSAGetLastError()),"error",0);return -1;}

A.sin_family = AF_INET;
A.sin_port = htons(23);

//SendMessage(0,hwndChk,0,(LPARAM) (LPSTR) "try to get host name");
H=gethostbyname(szSERVERt);
if (H==NULL) {MessageBox(0,"cannot get host","error",0); return-1;}
           
A.sin_addr.s_addr=*((unsigned long *) H->h_addr);


//SendMessage(0,hwndChk,0,(LPARAM) (LPSTR) "try to connect");
d=connect(s,(struct sockaddr *)&A,sizeof(A));
if (d!=0) {MessageBox(0,"cannot connect","error",0);}

------ I can understand above of this line
------ Next line  I couldn't understand.
------ they send s1 that i don't know what it means.
                                                         
s1[0]= (unsigned char) 0xff;s1[1]=(unsigned char) 0xfb;s1[2]=(unsigned char)0x18;
send(s,s1,3,0);
s1[0]= (unsigned char) 0xff;s1[1]=(unsigned char) 0xfc;s1[2]=(unsigned char) 0x20;
send(s,s1,3,0);
s1[0]= (unsigned char) 0xff;s1[1]=(unsigned char) 0xfc;s1[2]=(unsigned char) 0x23;
send(s,s1,3,0);
s1[0]= (unsigned char) 0xff;s1[1]=(unsigned char) 0xfc;s1[2]=(unsigned char) 0x24;
send(s,s1,3,0);

hear("CONNECT 1");
s2[0]=(unsigned char) 0xff;s2[1]=(unsigned char) 0xfa;s2[2]=(unsigned char) 0x18;s2[3]=0x0;s2[4]=0x76;s2[5]=(unsigned char) 0x74;
s2[6]=(unsigned char) 0x31;s2[7]=(unsigned char)0x30;s2[8]=(unsigned char)0x30;s2[9]=(unsigned char)0xff;s2[10]=(unsigned char)0xf0;
send(s,s2,11,0);

hear("CONNECT 2");
s1[0]= (unsigned char)0xff;s1[1]=(unsigned char)0xfd;s1[2]=(unsigned char)0x03;
send(s,s1,3,0);
s1[0]= (unsigned char)0xff;s1[1]=(unsigned char)0xfb;s1[2]=(unsigned char)0x01;
send(s,s1,3,0);
s1[0]= (unsigned char)0xff;s1[1]=(unsigned char)0xfc;s1[2]=(unsigned char)0x1f;
send(s,s1,3,0);
s1[0]= (unsigned char)0xff;s1[1]=(unsigned char)0xfe;s1[2]=(unsigned char)0x05;
send(s,s1,3,0);
s1[0]= (unsigned char)0xff;s1[1]=(unsigned char)0xfc;s1[2]=(unsigned char)0x21;
send(s,s1,3,0);
0
Comment
Question by:folktale
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1410712
Look into
TELNET PROTOCOL SPECIFICATION
http://www.faqs.org/rfcs/rfc854.html

There are details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now