Solved

How can I communicate with Telnet Server?

Posted on 1998-07-21
1
182 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 100 total points
ID: 1410712
Look into
TELNET PROTOCOL SPECIFICATION
http://www.faqs.org/rfcs/rfc854.html

There are details.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

632 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