473,685 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.RemoteHo st = "mail.rpi.e du"
telnet.RemotePo rt = 110
End Sub

Private Sub cmdConnect_Clic k()
telnet.Connect
cmdConnect.Enab led = False
End Sub

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

Private Sub cmdSendData_Cli ck()
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 50306
"Dan" <a@a.com> wrote in message news:<d7******* **********@twis ter.nyroc.rr.co m>...
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.RemoteHo st = "mail.rpi.e du"
telnet.RemotePo rt = 110
End Sub

Private Sub cmdConnect_Clic k()
telnet.Connect
cmdConnect.Enab led = False
End Sub

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

Private Sub cmdSendData_Cli ck()
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*******@eart hlink.net> wrote in message
news:fa******** *************** **@posting.goog le.com...
"Dan" <a@a.com> wrote in message

news:<d7******* **********@twis ter.nyroc.rr.co m>...
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.RemoteHo st = "mail.rpi.e du"
telnet.RemotePo rt = 110
End Sub

Private Sub cmdConnect_Clic k()
telnet.Connect
cmdConnect.Enab led = False
End Sub

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

Private Sub cmdSendData_Cli ck()
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
5224
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 up on the project for a while. I still have need for this, however, so I recently started thinking about alternatives. I suppose I could dig deep enough into option negotiation to use the socket module (with telnet as a guide), but I am hoping...
4
9301
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
9880
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 my code and inform me where i might be getting it wrong. I would appreciate if I got ideas of how to achieve this in a simpler way. Below is my code ===================================================================
5
33861
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 shouldn't be too complicated, I thought... I have yet to find any examples of being able to do this.
1
2327
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 ( byte incoming = new byte ) and then i tried to connect to a pop3 server... i logged in with user and pass cmomands and then i types "list" cmomand which lists all the mails in my mailbox with their filesize.. my problem just starts here that i...
1
2663
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
5178
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 destinations. must provide login security before make communication 2 telnet communication should not be a direct 1 to 1 communication and that must be as follows Web telnet client -à Web server (telnet client) -à destination (see figure 01)
0
1251
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 buttons 2 text box :
0
3848
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 get the correct return data from the device. Sometimes I get about 100 bytes and other times I get 3000 bytes. I even put a thread sleep but that still give me different return data from different devices. I know I am going to have to use an...
0
8512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8774
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7591
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6436
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5793
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2199
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.