473,421 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

Simple Telnet client using Winsock in VB6

Dan
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
..SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When
I type something into the textbox and send it, however, I get no response
whatsoever. I tested the _DataArrival event subroutine and it's not even
firing (except when I first connect). My guess is that Winsock's .SendData
method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out.
The source is pasted below. It consists of two textboxes (sending data and
reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because
it's adapted from MSDN's example library. Any help would be appreciated.

Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End
End Sub
Jul 17 '05 #1
2 50222
"Dan" <a@a.com> wrote in message news:<d7*****************@twister.nyroc.rr.com>...
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
.SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When
I type something into the textbox and send it, however, I get no response
whatsoever. I tested the _DataArrival event subroutine and it's not even
firing (except when I first connect). My guess is that Winsock's .SendData
method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out.
The source is pasted below. It consists of two textboxes (sending data and
reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because
it's adapted from MSDN's example library. Any help would be appreciated.

Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text
most telnet-based applications (including the standard mail protocol
on port 110) require that transmissions be terminated with CR/LF
pairs; without that the server assumes more data is coming and waits.
try this:
telnet.SendData txtSend.Text & vbCRLF

If that fails you'll need to find out what protocol the specific
server is using.
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End
don't use END. That is an abrupt, drastic termination of your app and
is NEVER needed. VB apps end normally when all forms are unloaded and
no code is running. In this case all you need is "Unload Me".
End Sub

Jul 17 '05 #2
Dan
"Bob Butler" <bu*******@earthlink.net> wrote in message
news:fa*************************@posting.google.co m...
"Dan" <a@a.com> wrote in message

news:<d7*****************@twister.nyroc.rr.com>...
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
.SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When I type something into the textbox and send it, however, I get no response whatsoever. I tested the _DataArrival event subroutine and it's not even firing (except when I first connect). My guess is that Winsock's ..SendData method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out. The source is pasted below. It consists of two textboxes (sending data and reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because it's adapted from MSDN's example library. Any help would be appreciated.
Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text


most telnet-based applications (including the standard mail protocol
on port 110) require that transmissions be terminated with CR/LF
pairs; without that the server assumes more data is coming and waits.
try this:
telnet.SendData txtSend.Text & vbCRLF

If that fails you'll need to find out what protocol the specific
server is using.
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End


don't use END. That is an abrupt, drastic termination of your app and
is NEVER needed. VB apps end normally when all forms are unloaded and
no code is running. In this case all you need is "Unload Me".
End Sub


Thank you, that was exactly it. And thanks for the advice regarding END.
That's definitely a fossil of my QBasic days.

-Dan
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Donnal Walter | last post by:
Several months ago I tried using the telnet module (on Windows XP) to communicate with a proprietary host on our network. This was unsuccessful due to problems with "option negotiation", and I gave...
4
by: Tim Tyler | last post by:
Has anyone ever built a JavaScript Telnet client? What about a JavaScript SSH client? -- __________ |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
4
by: Enos Meroka | last post by:
Hallo, Am trying to establish a telnet session with my C program. However, I seem not to able to get the prompt, after supplying the username and passowrd. could someone assist me in troubleshoot...
5
by: Greg Martz | last post by:
I'd like to do the following in C# and prefer using tcpclient rather than raw sockets... Connect to a unix box Login run date +%H%M%S retrieve the response. That's it, nothing more. This...
1
by: Serdar C. | last post by:
hi there i just write a program works like a telnet client (with AsyncCallback).... everything works fine but i have a problem with packets received... i set the received packet size to 32768 (...
1
by: Arif | last post by:
I want to develope a telnet cleint using C++ .net but I am beginner in c++ .net so i dont know whether any API's ,functions or classes are in C++ .net if u can help me then let me know
2
by: thilandeneth | last post by:
i need to do telnet via a web server please give me a idia to initiate the project following requirements are needed 1 Create web based custom telnet client to communicate with remote...
0
by: Link | last post by:
hello i want to make simple server client system that send data like that one : http://www.eggheadcafe.com/articles/20020323.asp just no console app well i want to make form with 2...
0
by: goroth | last post by:
I am trying to create a telnet client that will connect to several of my network devices on campus and change settings on the devices. So far I can connect with the code below, but I can't seem to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.