PDA

Click to See Complete Forum and Search --> : Microsoft TCP Winsock GetData() issue


neil147
Aug 12th, 2009, 04:33 AM
Hi guys

I'm pretty new to VB programming and am in the middle of developing an application to receive data over a TCP connection.
To test the application, I am connection to the port using Telnet from the Windows command prompt.
If I copy some data onto the clipboard (for example "ABCDEFG" and then paste it into the telnet session, the only data that gets received into the application and subsequently displayed in the window is the letter "A" (I.e the first character in the string that was sent.

What am I doing wrong? How do I get it to accept the whole string ?

Here is the code....
=========================================================
Private Sub Listener_DataArrival(ByVal bytesTotal As Long)
Dim MBMinitiator As String

Listener.GetData MBMinitiator
Listener.Close
'
MBMContent = MBMinitiator

Label1.Caption = MBMContent
'
Listener.Listen
End Sub
=========================================================

Thanks in advance..

DigiRev
Aug 14th, 2009, 04:54 PM
Label1.Caption = MBMContent

should be:

Label1.Caption = & Label1.Caption & MBMContent

Also, don't close the connection in the DataArrival() event...

neil147
Aug 15th, 2009, 06:23 AM
Hi DigiRev

Thanks for your help. I am getting more than 2 character being received now thanks. However, the results are not consistent.

For example, I sent the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and the first file contained "XYZ". I sent it a second time and the file contained "Z".

From setting breakpoints, it seems that the DataArrival() functon is called 26 times when "ABCDEFGHIJKLMNOPQRSTUVWXYZ" is sent.

How can I determine when receving data is complete?

Thanks again
Neil

DigiRev
Aug 18th, 2009, 09:32 PM
That's just the way telnet works. You should read up on the Telnet Protocol (http://support.microsoft.com/kb/231866).

I may be able to write an example later if you still need help...

neil147
Aug 20th, 2009, 11:01 AM
Hi DigiRev

I'm having trouble making sense of the the way that Telnet works to be honest.

An example would be fantastic fi you have time please. I would really appreciate that.

Many thanks for your help.

rudyking
Aug 26th, 2009, 06:09 AM
Try writing a simple form that acts as a client and try sending data that way.
Try this... (just copy and paste)
Private Sub Listener_DataArrival(ByVal bytesTotal As Long)
Dim MBMinitiator As String
Listener.GetData MBMinitiator, vbstring
Label1.Caption = label1.caption & MBMinitiator
End Sub

Oh, and I think you are having problems with Telnet because it runs in DOS. When you paste in DOS it sends it as keystrokes.

rudyking.gmail@com