Solved

How can I communicate with Telnet Server?

Posted on 1998-07-21
1
176 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Enable Clear Text in Win 8.1 7 44
C# Performance testing with Visual Studio Profession 2015 2 39
String manipulation in Visual Basic 7 62
Need more details 5 152
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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

777 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