Results 1 to 6 of 6

Thread: More fun with Winsock

  1. #1
    Guest
    Ok, I want to, IMMEDIATELY after winsock connects to the server (yes, this is TCP), then it'll send a list that you probably saw in the General VB forum:

    Winsock1.Connect
    Sleep 300 (or 5000; I'm contemplating both)
    Dim iFile As Integer
    For iFile = 0 To File1.ListCount - 1
    Winsock1.SendData File1.List(iFile)
    Next iFile

    But it brings back

    "Wrong protocol or connection state for the requested transaction or request"

    Any ideas?

    Sincerely,

    Jedi Drunken Llama

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    re:

    Its sending before the the winsocks has fully connected. Add this after the line winsock1.connect:

    Do until Winsock1.State = 7
    DoEvents
    Loop


    Give it a shot

  3. #3
    Guest
    I'm going to test that in a few seconds, as soon as a friend replies via ICQ. Now, do I put

    Dim iFile As Integer

    For iFile = 0 To File1.ListCount - 1
    Winsock1.SendData File1.List(iFile)
    Next iFile

    where you have "DoEvents"? I'm sorry, I'm very new at this. Hopefully, I can someday stop asking the questions and start answering them.

    Sincerely,

    Jedi Drunken Llama

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    No, the Do Loop is there to force your code to wait until the connection has completed

    Put the Do Loop before your For Next loop.

  5. #5
    Guest
    The above worked, and thanks for it! Now there's a new problem, and I don't know if this goes into General VB or into this forum; since I started it here, I'll post it here.

    Now then, I have a list box set up so that the information that was sent in the discussion earlier will be reported there. Here's what I have:

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
    Winsock1.GetData strData
    List1.AddItem strData & vbCrLf
    End Sub

    Unfortunately, it lumps all of the results into two lines (for both the client and server). Any idea?

    Sincerely,

    Jedi Drunken Llama

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    See my reply to pir8eer's post: Sending and receiving in winsock gets mixed up!. It may shed some light on your problem.

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