Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I communicate with Telnet Server?

Posted on 1998-07-21
1
Medium Priority
?
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

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

There are details.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

704 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