Results 1 to 6 of 6

Thread: Microsoft TCP Winsock GetData() issue

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    3

    Microsoft TCP Winsock GetData() issue

    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..

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Microsoft TCP Winsock GetData() issue

    Label1.Caption = MBMContent

    should be:

    Label1.Caption = & Label1.Caption & MBMContent

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

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    3

    Re: Microsoft TCP Winsock GetData() issue

    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

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Microsoft TCP Winsock GetData() issue

    That's just the way telnet works. You should read up on the Telnet Protocol.

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

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    3

    Re: Microsoft TCP Winsock GetData() issue

    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.

  6. #6
    Member
    Join Date
    Mar 2006
    Posts
    46

    Re: Microsoft TCP Winsock GetData() issue

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width